Class Queue
Distributed Queue
Declaration
class Queue
source linkDocumentation
This allows multiple clients to share futures or small bits of data between
each other with a multi-producer/multi-consumer queue. All metadata is
sequentialized through the scheduler.
Elements of the Queue must be either Futures or msgpack-encodable data
(ints, strings, lists, dicts). All data is sent through the scheduler so
it is wise not to send large objects. To share large objects scatter the
data and share the future instead.
.. warning::
This object is experimental and has known issues in Python 2
Attributes
- name : string
Name used by other clients and the scheduler to identify the queue. If
not given, a random name will be generated.
- client : Client
Client used for communication with the scheduler. Defaults to the
value of ``Client.current()``.
- maxsize : int
Number of items allowed in the queue. If 0 (the default), the queue
size is unbounded.
Examples
>>> from dask.distributed import Client, Queue # doctest: +SKIP
>>> client = Client() # doctest: +SKIP
>>> queue = Queue('x') # doctest: +SKIP
>>> future = client.submit(f, x) # doctest: +SKIP
>>> queue.put(future) # doctest: +SKIP
See also
Variable: shared variable between clients
Methods
▷ def __init__(self, name=None, client=None, maxsize=0) ▶ def get(self, timeout=None, batch=False, **kwargs) Get data from the queue
Parameters
- timeout : number or string or timedelta
Time in seconds to wait before timing out.
Instead of number of seconds, it is also possible to specify
a timedelta in string format, e.g. "200ms".
- batch : boolean, int
If True then return all elements currently waiting in the queue.
If an integer than return that many elements from the queue
If False (default) then return one item at a time
▶ def put(self, value, timeout=None, **kwargs) Put data into the queue
▷ def qsize(self, **kwargs) Current number of elements in the queue
Reexports