mailbox_supervisor
Keeps a pod's mailbox connected to the message service.
Attributes: MAX_RECONNECT_BACKOFF_SECONDS: The longest wait between two reconnection attempts.
Classes
MailboxSupervisor
class MailboxSupervisor( mailbox: _PodMailbox, *, pod_name: str, username: str, dataset_names: Callable[[], list[str]], pod_vitals: _PodVitals,):Connects a pod's mailbox and keeps it listening across outages.
A pod whose message service cannot be reached stays up and runs the work
that needs only the Hub and local resources: its scheduled and recovered
background runs, indexing, health reporting and the local APIs. The
supervisor reconnects with exponential backoff, capped at
MAX_RECONNECT_BACKOFF_SECONDS, and restarts the listener. While
disconnected the pod receives no task requests, dataset links or
interactive triggers.
Arguments
mailbox: The pod's mailbox.pod_name: The pod's name, as registered with the message service.username: The pod owner's username, which the registered names are guarded against.dataset_names: Returns the datasets to register on each connect, so a reconnect registers any a config reload added.pod_vitals: Where the connection state is recorded for/health.
Attributes
on_connected: Called on the pod's event loop after every successful connect, if set.
Variables
connected : bool- Whether the mailbox is connected to the message service.
Methods
connect
async def connect(self) ‑> bool:Register the pod and its datasets with the message service, once.
A connection error is recorded and logged rather than raised, so the pod can come up without the message service.
Returns Whether the pod is now connected.
run
async def run(self) ‑> None:Keep the mailbox connected and listening until cancelled.
Returns when the listener ends on its own, which the pod treats as a clean stop. A connection error from a connect or from the listener starts a reconnection; any other error propagates.