Class Variable
Distributed Global Variable
Declaration
class Variable
source linkDocumentation
This allows multiple clients to share futures and data between each other
with a single mutable variable. All metadata is sequentialized through the
scheduler. Race conditions can occur.
Values must be either Futures or msgpack-encodable data (ints, lists,
strings, etc..) All data will be kept and sent through the scheduler, so
it is wise not to send too much. If you want to share a large amount of
data then ``scatter`` it 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 variable.
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()``.
Examples
>>> from dask.distributed import Client, Variable # doctest: +SKIP
>>> client = Client() # doctest: +SKIP
>>> x = Variable('x') # doctest: +SKIP
>>> x.set(123) # docttest: +SKIP
>>> x.get() # docttest: +SKIP
123
>>> future = client.submit(f, x) # doctest: +SKIP
>>> x.set(future) # doctest: +SKIP
See also
Queue: shared multi-producer/multi-consumer queue between clients
Methods
▷ def __init__(self, name=None, client=None, maxsize=0) ▶ def delete(self) Delete this variable
Caution, this affects all clients currently pointing to this variable.
▶ def get(self, timeout=None, **kwargs) Get the value of this variable
▶ def set(self, value, **kwargs) Set the value of this variable
Reexports