Skip to main content

base

Shared behaviour for progress event reporters.

A reporter holds the identity of one preprocessing pass or one task run, stamps each event with a UTC timestamp and the next sequence number, and hands it to a ProgressEventSender. Reporter methods never raise: reporting progress must not fail the run being reported on.

Error events carry a reason that is a string literal from the calling code plus, optionally, the class name of the exception. Exception messages are never sent, because they can quote file paths and data values, and these events leave the site.

Module​

Functions​

never_raises​

def never_raises(method: Callable[P, None]) ‑> Callable[P, None]:

Log and swallow any exception raised by a reporting method.

Arguments

  • method: The reporting method to guard.

Returns The guarded method.

Classes​

EventReporter​

class EventReporter(sender: ProgressEventSender | None, start_sequence_number: int):

Base for progress event reporters: sequence numbering and safe submission.

Subclasses build their events in methods guarded by never_raises and hand each one to _submit.

Every event a run emits carries a sequence number: its position among that run's events, counting up by one per event in the order they were reported. Consumers order a run's events by it, since timestamps can tie and events can arrive out of order. A number is never reused within a run, so a retried send overwrites rather than duplicates the stored event. The sequence has a gap wherever an event was dropped.

Arguments

  • sender: Delivers the events. None makes the reporter a no-op.
  • start_sequence_number: The sequence number of the first event.

Variables​

  • next_sequence_number : int - The sequence number the next event will carry.
  • sender : ProgressEventSender | None - The sender this reporter hands its events to, if any.

    Read-only: a caller composing a second reporter for the same run shares this one rather than holding the sender separately.