Store
Store of heterogeneous objects with optional filter on get.
Store
A collection of heterogeneous objects.
Blocking get() accepts an optional filter callable. The first item for which filter(item) is True (or any item when filter is None) is removed and returned. If no matching item is available, the process blocks.
Blocking put() blocks only if the store is at capacity.
get(filter=None)
Return an Event whose value is the first matching item.
If a matching item is already available, the Event is pre-triggered and _on_cancel is set so that FirstOf can restore the item.
put(item)
Return an Event that resolves to True when item is stored.
Delivers directly to a matching waiting getter if one exists, adds to items if there is capacity, or blocks.
try_get(filter=None)
Remove and return the first matching item, or raise StoreEmpty.
try_put(item)
Add item to the store, or raise StoreFull.
StoreEmpty
Bases: Exception
Raised by Store.try_get() when no matching item is available.
StoreFull
Bases: Exception
Raised by Store.try_put() when the store is at capacity.