pythia.event_stream.memory#

Memory-backed event stream storage.

class pythia.event_stream.memory.Backend(uri: str)[source]#

Bases: Backend

Simple event stream client to store incoming data into a deque.

By default, the deque does not have a limit so the dev mus pay special attention to avoid the deque from growing indefinitely. Alternatively, a bounded deque could be used, or a watcher to pop old-enough elements in a background worker.

Initialize a backend from its uri.

Parameters:

uri – connection string.

_abc_impl = <_abc_data object>#
_deque: deque | None = None#
_deque_constructor#

Allow to customize the storage (eg to set maxlen).

alias of deque

connect() None[source]#

Fetch stream-specific deque from global container.

property deque: deque#

Internal container lazy-loader.

Returns:

Initialized deque.

post(data) None[source]#

Append an element into the deque.

Parameters:

data – the data to append. Can be any python object.