httk.workflow.supervision¶
Structured, argv-only process supervision for native runners.
Every event is dispatched to the in-process monitors and to the executable checkers under one supervisor-wide lock, so a monitor is never entered concurrently with itself or with another monitor, and a checker never receives an interleaved line on its stdin. A monitor therefore does not have to be thread-safe, but it must return quickly: it delays the whole event stream.
Attributes¶
Seconds between the |
|
Seconds between polls of a followed file that produced no new data. |
|
Bytes of a stream retained in the report when no output path is given. |
|
Bytes of a stream retained in the report when an output path is given. |
|
Diagnostics retained in one report before the middle is dropped. |
Classes¶
One event delivered to an in-process or executable checker. |
|
A structured observation made while supervising a program. |
|
A file to follow while the child process is running. |
|
A versioned executable checker. |
|
The complete result of one supervised command. |
|
Run one command, stream its output, and terminate its process group safely. |
Module Contents¶
- httk.workflow.supervision.DEFAULT_TICK_INTERVAL = 1.0[source]¶
Seconds between the
tickevents delivered to monitors and checkers.
- httk.workflow.supervision.DEFAULT_FOLLOW_INTERVAL = 0.25[source]¶
Seconds between polls of a followed file that produced no new data.
- httk.workflow.supervision.DEFAULT_CAPTURE_LIMIT = 4194304[source]¶
Bytes of a stream retained in the report when no output path is given.
- httk.workflow.supervision.DEFAULT_TAIL_LIMIT = 65536[source]¶
Bytes of a stream retained in the report when an output path is given.
- httk.workflow.supervision.DEFAULT_DIAGNOSTIC_LIMIT = 512[source]¶
Diagnostics retained in one report before the middle is dropped.
- class httk.workflow.supervision.SourceEvent[source]¶
One event delivered to an in-process or executable checker.
- class httk.workflow.supervision.Diagnostic[source]¶
A structured observation made while supervising a program.
- class httk.workflow.supervision.FollowSource[source]¶
A file to follow while the child process is running.
- path: pathlib.Path[source]¶
- class httk.workflow.supervision.CheckerSpec[source]¶
A versioned executable checker.
- sources: tuple[FollowSource, Ellipsis] = ()[source]¶
- classmethod from_mapping(value: collections.abc.Mapping[str, object]) CheckerSpec[source]¶
- class httk.workflow.supervision.ProcessReport[source]¶
The complete result of one supervised command.
stdoutandstderrare bounded: when an output path was given they hold at most the run’s tail limit and the file named bystdout_pathorstderr_pathis authoritative; otherwise they hold at most the run’s capture limit.stdout_bytesandstderr_bytesalways count every byte the program produced, andstdout_truncatedandstderr_truncatedsay whether anything was dropped from the retained tail.- diagnostics: tuple[Diagnostic, Ellipsis][source]¶
- write(path: str | os.PathLike[str]) pathlib.Path[source]¶
- class httk.workflow.supervision.ProcessSupervisor(*, monitors: collections.abc.Sequence[EventMonitor] = (), checkers: collections.abc.Sequence[CheckerSpec] = (), follow: collections.abc.Sequence[FollowSource] = ())[source]¶
Run one command, stream its output, and terminate its process group safely.
Monitors and checkers observe the same event stream under one lock, so an in-process monitor does not have to be thread-safe. Whatever happens during a run - including an exception raised by the caller’s monitor - the signal handlers are restored, the child’s process group is terminated and reaped, the reader threads are joined, and the output handles are closed before
run()returns or propagates.- run(argv: collections.abc.Sequence[str], *, timeout: float | None = None, cwd: str | os.PathLike[str] | None = None, environment: collections.abc.Mapping[str, str] | None = None, termination_grace: float = 10.0, stdout_path: str | os.PathLike[str] | None = None, stderr_path: str | os.PathLike[str] | None = None, tick_interval: float = DEFAULT_TICK_INTERVAL, follow_interval: float = DEFAULT_FOLLOW_INTERVAL, capture_limit: int = DEFAULT_CAPTURE_LIMIT, tail_limit: int = DEFAULT_TAIL_LIMIT, diagnostic_limit: int = DEFAULT_DIAGNOSTIC_LIMIT) ProcessReport[source]¶
Run one command to completion and return its structured report.