Module

_runtime

Runtime detection utilities.

Detects GIL state and determines the appropriate worker mode for the current Python interpreter. Used by the supervisor to decide between thread-based (nogil) and process-based (GIL) worker spawning.

Functions

is_gil_enabled 0 bool
Check whether the GIL is active in the current interpreter. Returns ``False`` …
def is_gil_enabled() -> bool

Check whether the GIL is active in the current interpreter.

ReturnsFalse on Python 3.14t (free-threading) and Trueon standard GIL-enabled builds. Falls back toTrueon Python < 3.13 wheresys._is_gil_enableddoes not exist.

Returns
bool
detect_worker_mode 0 WorkerMode
Choose the worker spawning strategy based on GIL state.
def detect_worker_mode() -> WorkerMode
Returns
WorkerMode
default_worker_count 0 int
Return a sensible default worker count based on available CPUs. Returns ``os.c…
def default_worker_count() -> int

Return a sensible default worker count based on available CPUs.

Returnsos.cpu_count() or 1when the CPU count cannot be determined.

Returns
int