Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (33 sloc) 1.13 KB

Local Cluster

For convenience you can start a local cluster from your Python session.

>>> from distributed import Client, LocalCluster
>>> cluster = LocalCluster()
LocalCluster("", workers=8, ncores=8)
>>> client = Client(cluster)
<Client: scheduler= processes=8 cores=8>

You can dynamically scale this cluster up and down:

>>> worker = cluster.add_worker()
>>> cluster.remove_worker(worker)

Alternatively, a LocalCluster is made for you automatically if you create an Client with no arguments:

>>> from distributed import Client
>>> client = Client()
>>> client
<Client: scheduler= processes=8 cores=8>


Within a Python script you need to start a local cluster in the if __name__ == '__main__' block:

if __name__ == '__main__':
    cluster = LocalCluster()
    client = Client(cluster)
    # Your code follows here


.. currentmodule:: distributed.deploy.local

.. autoclass:: LocalCluster