Class Server

Dask Distributed Server

Declaration

class Server
source link

Documentation

Superclass for endpoints in a distributed cluster, such as Worker
and Scheduler objects.

**Handlers**

Servers define operations with a ``handlers`` dict mapping operation names
to functions.  The first argument of a handler function will be a ``Comm``
for the communication established with the client.  Other arguments
will receive inputs from the keys of the incoming message which will
always be a dictionary.

>>> def pingpong(comm):
...     return b'pong'

>>> def add(comm, x, y):
...     return x + y

>>> handlers = {'ping': pingpong, 'add': add}
>>> server = Server(handlers)  # doctest: +SKIP
>>> server.listen('tcp://0.0.0.0:8000')  # doctest: +SKIP

**Message Format**

The server expects messages to be dictionaries with a special key, `'op'`
that corresponds to the name of the operation, and other key-value pairs as
required by the function.

So in the example above the following would be good messages.

*  ``{'op': 'ping'}``
*  ``{'op': 'add', 'x': 10, 'y': 20}``

Methods

Subclasses

Reexports