Server implementations

Like RPC Client, servers are top-level instances that most user code should interact with. They provide runnable functions that are combined with transports, protocols and dispatchers to form a complete RPC system.

class tinyrpc.server.RPCServer(transport, protocol, dispatcher)

High level RPC server.


Handle requests forever.

Starts the server loop in which the transport will be polled for a new message.

After a new message has arrived, _spawn() is called with a handler function and arguments to handle the request.

The handler function will try to decode the message using the supplied protocol, if that fails, an error response will be sent. After decoding the message, the dispatcher will be asked to handle the resultung request and the return value (either an error or a result) will be sent back to the client using the transport.

After calling _spawn(), the server will fetch the next message and repeat.

class tinyrpc.server.gevent.RPCServerGreenlets

Asynchronous RPCServer.

This implementation of RPCServer uses gevent.spawn() to spawn new client handlers, result in asynchronous handling of clients using greenlets.