Undocumented
| Function | _build |
Build a Pdb subclass that suspends sandbox restrictions during the REPL. |
| Function | _install |
Set sys.breakpointhook to the workflow hook if it isn't already. |
| Function | _relax |
Allow breakpoint() past the sandbox so it can reach the worker hook. |
| Function | _temporal |
sys.breakpointhook that handles breakpoint() inside workflows. |
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.
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.
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.