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.

Parameters:
receive_one_message()

Handle a single request.

Polls the transport 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.

serve_forever()

Handle requests forever.

Starts the server loop continuously calling receive_one_message() to process the next incoming request.

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.