pymllm.orchestrator.ipc_utils¶
ZMQ IPC utilities for inter-process communication.
Provides helpers to generate unique IPC addresses and create pre-configured ZMQ sockets so that every process uses the same conventions.
Functions¶
|
Return an |
|
Create a ZMQ socket, bind or connect it, and return it. |
|
Close a ZMQ socket, ignoring errors. |
|
Remove IPC socket files for the given engine (or all if no id given). |
|
Configure logging for a spawned subprocess. |
Module Contents¶
- pymllm.orchestrator.ipc_utils.make_ipc_address(name, unique_id=None)¶
Return an
ipc://address for name, optionally scoped by unique_id.- Parameters:
name (str) – Logical channel name, e.g.
"rr_to_tokenizer".unique_id (Optional[str]) – Per-engine identifier (typically
str(os.getpid())) to avoid collisions when multiple engines run on the same host.
- Return type:
str
- pymllm.orchestrator.ipc_utils.create_zmq_socket(ctx, socket_type, address, bind)¶
Create a ZMQ socket, bind or connect it, and return it.
- Parameters:
ctx (zmq.Context) – A
zmq.Contextshared within the process.socket_type (int) – One of
zmq.PUSH,zmq.PULL,zmq.PAIR, etc.address (str) – The
ipc://address string.bind (bool) – If
Truethe socket callsbind; otherwiseconnect.
- Return type:
zmq.Socket
- pymllm.orchestrator.ipc_utils.close_zmq_socket(sock)¶
Close a ZMQ socket, ignoring errors.
- Parameters:
sock (zmq.Socket)
- Return type:
None
- pymllm.orchestrator.ipc_utils.cleanup_ipc_files(unique_id=None)¶
Remove IPC socket files for the given engine (or all if no id given).
- Parameters:
unique_id (Optional[str])
- Return type:
None
- pymllm.orchestrator.ipc_utils.setup_subprocess_logging(log_level='info')¶
Configure logging for a spawned subprocess.
When Python spawns a subprocess (
mp.set_start_method('spawn')), the child starts with a blank logging configuration. Call this function at the very beginning of every subprocess entry point so that log records are emitted at the correct level.- Parameters:
log_level (str) – Case-insensitive level name, e.g.
"debug","info","warning".- Return type:
None