gil_watchdog
Dump every thread's stack when a flow process stops getting the GIL.
Prefect judges a flow run alive by a heartbeat that a Python thread emits every 30 s. Anything that holds the GIL for longer than the zombie reaper's window silences it, and the run is reaped as crashed while it is still working. Such a stall leaves no trace in the logs, because no Python thread can log during it.
faulthandler.dump_traceback_later arms a watchdog on a C thread that needs no
GIL. GilStallWatchdog keeps pushing that deadline back from a Python thread,
so it only fires when no Python thread has run for the whole timeout, and the
stacks it writes to stderr name the call holding the GIL.
Classes
GilStallWatchdog
class GilStallWatchdog( timeout_seconds: int, log: logging.Logger | logging.LoggerAdapter[Any] = <Logger bitfount.runtimes.gil_watchdog (DEBUG)>,):Dumps all thread stacks to stderr if the GIL is held for timeout_seconds.
One per process at a time: faulthandler has a single deadline.
Arguments
timeout_seconds: How long no Python thread may run before the dump.0disables the watchdog.log: Where to report arming and any stall detected after the fact.
Methods
start
def start(self) ‑> None:Arm the watchdog and start pushing its deadline back.
stop
def stop(self) ‑> None:Stop the re-arming thread and cancel the pending dump.