@contextmanager
def worker_client(
timeout=None,
separate_thread=True,
)
This context manager is intended to be called within functions that we run
on workers. When run as a context manager it delivers a client
``Client`` object that can submit other tasks directly from that worker.
Parameters
Examples
>>> def func(x):
... with worker_client(timeout="10s") as c: # connect from worker back to scheduler
... a = c.submit(inc, x) # this task can submit more tasks
... b = c.submit(dec, x)
... result = c.gather([a, b]) # and gather results
... return result
>>> future = client.submit(func, 1) # submit func(1) on cluster
See also
get_worker
get_client
secede
Reexports