kilter.service.util module

Common helper utilities

class Broadcast[source]

Bases: Condition, Generic[T]

A reliable, blocking message queue for delivering to multiple listening tasks

Listeners must acquire the lock (by using the Broadcast instance as a context manager) before calling Broadcast.receive() or it will fail. If a listener is repeatedly awaiting messages in a loop, the loop should be inside the locked context or messages may be lost to race conditions.

async pre_receive_hook() None[source]

A hook for subclasses to inject synchronisation instructions before awaiting objects

async post_send_hook() None[source]

A hook for subclasses to inject synchronisation instructions after sending objects

async shutdown_hook() None[source]

A hook for subclasses to inject cleanup or synchronisation instructions on close

Users must ensure this method is called, especially if using a subclass which implements it.

async abort(exc: BaseException | type[BaseException]) None[source]

Send a notification to all listeners to abort by raising an exception

async send(obj: T) None[source]

Send a message object and block until all listeners have received it

async receive() T[source]

Listen for a single message and return it once it arrives

qualname(func: Fn) str[source]

Return a qualified name for a callable