module documentation

Undocumented

Function _build_workflow_pdb_class Build a Pdb subclass that suspends sandbox restrictions during the REPL.
Function _install_workflow_breakpoint_hook Set sys.breakpointhook to the workflow hook if it isn't already.
Function _relax_sandbox_for_debugger Allow breakpoint() past the sandbox so it can reach the worker hook.
Function _temporal_workflow_breakpoint_hook sys.breakpointhook that handles breakpoint() inside workflows.
def _build_workflow_pdb_class() -> type: (source)

Build a Pdb subclass that suspends sandbox restrictions during the REPL.

pdb's cmdloop touches readline.get_completer and other sandbox-restricted internals each time it interacts with the user; we bracket each interaction with _sandbox_unrestricted.value = True and restore the previous value afterwards. Outside the REPL the sandbox stays intact.

pdb is imported lazily because it's a debug-only dependency that pulls in cmd/bdb/linecache; no reason to pay that cost at worker import time.

def _install_workflow_breakpoint_hook(): (source)

Set sys.breakpointhook to the workflow hook if it isn't already.

def _relax_sandbox_for_debugger(workflow_runner: WorkflowRunner) -> WorkflowRunner: (source)

Allow breakpoint() past the sandbox so it can reach the worker hook.

The sandbox flags breakpoint as non-deterministic by default; without this relaxation the call raises before our breakpoint hook can run. Once inside the hook, the hook itself enters sandbox_unrestricted() for the duration of the debugger session, so pdb's internals (readline, os.environ, etc.) aren't blocked either — without permanently dropping sandbox checks for the rest of workflow execution.

def _temporal_workflow_breakpoint_hook(*args: object, **kwargs: object) -> object: (source)

sys.breakpointhook that handles breakpoint() inside workflows.

Only installed when debug_mode is enabled on the Worker. From inside a workflow activation: drops the user into a custom Pdb at the workflow's own frame, with sandbox restrictions suspended during the REPL. From anywhere else (test code, helpers, etc.): delegates to whatever hook was previously installed.