— Store type resources

This module contains all Store like resources.

Stores model the production and consumption of concrete objects. The object type is, by default, not restricted. A single Store can even contain multiple types of objects.

Beside Store, there is a FilterStore that lets you use a custom function to filter the objects you get out of the store.

class, capacity=inf)

Models the production and consumption of concrete Python objects.

Items put into the store can be of any type. By default, they are put and retrieved from the store in a first-in first-out order.

The env parameter is the Environment instance the container is bound to.

The capacity defines the size of the Store and must be a positive number (> 0). By default, a Store is of unlimited size. A ValueError is raised if the value is negative.

items = None

List of the items within the store.


The maximum capacity of the store.


Create a new StorePut event.

alias of StorePut


Create a new StoreGet event.

alias of StoreGet

class, capacity=inf)

The FilterStore subclasses Store and allows you to only get items that match a user-defined criteria.

This criteria is defined via a filter function that is passed to get(). get() only considers items for which this function returns True.


In contrast to Store, processes trying to get an item from FilterStore won’t necessarily be processed in the same order that they made the request.

Example: The store is empty. Process 1 tries to get an item of type a, Process 2 an item of type b. Another process puts one item of type b into the store. Though Process 2 made his request after Process 1, it will receive that new item because Process 1 doesn’t want it.


The type to be used for the get_queue.

alias of FilterQueue


Create a new FilterStoreGet event.

alias of FilterStoreGet

class, item)

Put item into the store if possible or wait until it is.

item = None

The item to put into the store.


Get an item from the store or wait until one is available.

class, filter=lambda item: True)

Get an item from the store for which filter returns True. This event is triggered once such an event is available.

The default filter function returns True for all items, and thus this event exactly behaves like StoreGet.

filter = None

The filter function to use.


The queue inherits list and modifies __getitem__() and __bool__() to appears to only contain events for which the store‘s item queue contains proper item.


Get the keyth event from all events that have an item available in the corresponding store’s item queue.


Return True if the queue contains an event for which an item is available in the corresponding store’s item queue.


Provided for backwards compatability: __bool__() is only used from Python 3 onwards.