Class Server
Dask Distributed Server
Declaration
class Server
source linkDocumentation
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
▶ def __init__(self, handlers, blocked_handlers=None, stream_handlers=None, ...) def __init__(
self,
handlers,
blocked_handlers=None,
stream_handlers=None,
connection_limit=512,
deserialize=True,
serializers=None,
deserializers=None,
connection_args=None,
timeout=None,
io_loop=None,
)
Overrides
This method is overriden in:
▷ def address(self) @property The address this Server can be contacted on.
@property
def address(self)
▷ def close(self) @gen.coroutine @gen.coroutine
def close(self)
Overrides
This method is overriden in:
▷ def listen_address(self) @property The address this Server is listening on. This may be a wildcard address such as `tcp://0.0.0.0:1234`.
@property
def listen_address(self)
@property
def listener(self)
▶ def port(self) @property The port number this Server is listening on.
This will raise ValueError if the Server is listening on a
non-IP based protocol.
This starts all PeriodicCallbacks stored in self.periodic_callbacks if
they are not yet running. It does this safely on the IOLoop.
@property
def status(self)
▷ def status(self, new_status) @status.setter @status.setter
def status(
self,
new_status,
)
Subclasses
Reexports