Quirrel4.41.0

debug.set_script_watchdog_timeout_msec

Defined in module "debug"
from "debug" import set_script_watchdog_timeout_msec
set_script_watchdog_timeout_msec(timeout_msec: int): int

Sets the script watchdog timeout in milliseconds and returns the previous value

Parameters

timeout_msecintmilliseconds of wall-clock time a script may run before the watchdog raises an error; 0 turns the watchdog off

Return value

The timeout that was in effect before this call.

Notes

The watchdog guards against a script that never returns control, such as one caught in an infinite loop. The VM checks the elapsed time periodically while running bytecode, not on every single instruction, and raises a catchable "Watchdog: too long execution of quirrel script" error once the timeout is exceeded. Setting a new timeout also resets the clock, the same as script_watchdog_kick does.

Example

examples/debug/set_script_watchdog_timeout_msec.nut
from "debug" import set_script_watchdog_timeout_msec

println("set_script_watchdog_timeout_msec(5000) =", set_script_watchdog_timeout_msec(5000)) // 0: no timeout was set yet
println("set_script_watchdog_timeout_msec(0) =", set_script_watchdog_timeout_msec(0))    // 5000: the value just set
Output:
set_script_watchdog_timeout_msec(5000) = 0
set_script_watchdog_timeout_msec(0) = 5000

See also

script_watchdog_kickResets the script watchdog timer
debugmodule index