Firehose

class passengersim.driver.Firehose[source]

Bases: object

Mixin for attaching and retrieving simulation firehose outputs.

This helper expects subclasses to provide an eng attribute with the core firehose logger methods. Writable destinations are cached locally so buffered output can be retrieved after the engine flushes pending messages.

Methods

__init__()

attach_firehose(topic, destination, *[, ...])

Attach a firehose logger destination for a topic.

get_firehose(topic)

Return the cached writable firehose destination for a topic.

Attributes

eng

eng : SimulationEngine
attach_firehose(topic: str, destination: str | bool | TextIO | None, *, orig: str | None = None, dest: str | None = None, segment: str | None = None) None[source]

Attach a firehose logger destination for a topic.

Parameters:
topic : str

Firehose topic name to route from the simulation engine.

destination : str or bool or file-like or None

Destination passed through to the engine. Writable destinations are also stored locally so they can be returned by get_firehose().

orig : str or None, default None

For the "choice" topic, only log customers whose demand has this origin.

dest : str or None, default None

For the "choice" topic, only log customers whose demand has this destination.

segment : str or None, default None

For the "choice" topic, only log customers whose demand has this segment.

Notes

Choice filters use exact, case-sensitive matches. Omitted filters are wildcards. Demand filters are not supported by other firehose topics.

get_firehose(topic: str) TextIO | None[source]

Return the cached writable firehose destination for a topic.

Parameters:
topic : str

Firehose topic name to look up.

Returns:

TextIO or None – The cached writable destination for topic, if one was attached.

Notes

Pending firehose log output is flushed from the engine before the cached destination is returned.