Running Callbacks

pcapkit.utilities.callbacks holds run_callbacks(), which calls every registered callback whatever an earlier one raised. Reassembly and flow tracing run their callbacks through it, so both follow the ruling recorded on Reassembly Integration (#2881). It behaves the same on every interpreter, so it is not in compat; see Choosing Between utilities and corekit.

Added in version 1.7.0.

pcapkit.utilities.callbacks.run_callbacks(callbacks, argument, *, logger, subject)[source]

Call each callback with argument, every one whatever the others raise.

Parameters:
  • callbacks (Iterable[Callable[[_T], Any]]) – callbacks to call, in order

  • argument (_T) – the only argument each is called with

  • logger (Logger) – the caller’s logger, which records a later error

  • subject (str) – what the callbacks are for, leading that record

Raises:

Exception – The first Exception a callback raised, once the last has run.

Return type:

None

One raising an Exception does not stop the rest: the first such error is re-raised once all have run, and a later one logged at debug level with its traceback. Any other BaseException propagates at once, dropping an earlier error.