pynenc.runner.shutdown_diagnostics

Shutdown diagnostics utilities for runner termination events.

Centralises signal classification, system environment collection, and structured logging so every runner produces consistent, actionable output on SIGTERM/OOM.

Module Contents

Classes

Functions

classify_signal

Classify a signal number into a ShutdownReason.

_system_info

log_runner_shutdown

Log structured diagnostics for a runner shutdown event.

API

class pynenc.runner.shutdown_diagnostics.ShutdownReason[source]

Bases: enum.StrEnum

NORMAL

‘auto(…)’

SIGTERM

‘auto(…)’

SIGINT

‘auto(…)’

OOM_KILLED

‘auto(…)’

UNKNOWN_SIGNAL

‘auto(…)’

pynenc.runner.shutdown_diagnostics.classify_signal(signum: int | None) pynenc.runner.shutdown_diagnostics.ShutdownReason[source]

Classify a signal number into a ShutdownReason.

pynenc.runner.shutdown_diagnostics._system_info() dict[str, Any][source]
pynenc.runner.shutdown_diagnostics.log_runner_shutdown(logger: logging.Logger, runner_cls: str, runner_id: str, signum: int | None, *, processes: dict[str, tuple[Process, str | None]] | None = None, threads: dict[str, tuple[Thread, str | None]] | None = None, waiting_inv_ids: list[str] | None = None) None[source]

Log structured diagnostics for a runner shutdown event.

Collects system environment info automatically. Processes and threads are passed as dicts mapping an identifier to (object, invocation_id_or_None).

Parameters:
  • logger (Logger) – Logger to write to.

  • runner_cls (str) – Runner class name.

  • runner_id (str) – Runner instance ID.

  • signum (int | None) – Signal that triggered shutdown, if any.

  • processes – Child processes keyed by runner_id.

  • threads – Active threads keyed by an identifier.

  • waiting_inv_ids – Invocations blocked waiting for results.