Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Crane04/esem/llms.txt
Use this file to discover all available pages before exploring further.
shutdown() stops the Python worker process that was spawned by esem-bridge. It closes the worker’s stdin (causing the Python process to exit naturally), clears the internal pending-request map, and resets internal state so that a new worker can be spawned the next time python() is called. Call it in long-running applications — servers, daemons, background jobs — once you know Python calls are no longer needed.
Signature
Parameters
shutdown() takes no parameters.
What it does
- Closes the worker’s stdin — the Python worker reads JSON-RPC messages from stdin; ending that stream causes the worker process to exit cleanly.
- Clears the pending-request map — any request objects waiting for a response are removed from memory. In-flight calls are not actively rejected; call
shutdown()only after all outstandingawaits have settled to avoid losing results. - Resets internal state —
workerProcessand the ready-promise are reset, so the nextpython()call will spawn a fresh worker transparently.
Usage
Automatic signal registration
esem-bridge registersshutdown() on common Node.js process events so that short scripts that simply exit after their last await do not need to call it manually:
For short scripts that exit immediately after their last
await, you do not need to call shutdown() yourself. esem-bridge hooks into process.on("exit") and shuts the worker down automatically when Node.js exits.