Structure of tinyrpc


tinyrpc is constructed around the RPCServer and RPCClient classes.

They in turn depend on the RPCDispatcher, RPCProtocol, ServerTransport and ClientTransport classes as visualized in the image below.


Of these RPCProtocol, ServerTransport and ClientTransport are abstract base classes.

Each layer is useful “on its own” and can be used separately. If you just need to decode a jsonrpc message, without passing it on or sending it through a transport, the JSONRPCProtocol-class is completely usable on its own.

Likewise the RPCDispatcher could be used to dispatch calls in a commandline REPL like application.


The transport classes are responsible for receiving and sending messages. No assumptions are made about messages, except that they are of a fixed size. Messages are received and possibly passed on as Python bytes objects.

In an RPC context, messages coming in (containing requests) are simply called messages, a message sent in reply is called a reply. Replies are always serialized responses.


The protocol class(es) are responsible for two tasks:

  • they implement the protocol, defining how method names, method parameters and errors are represented in requests and responses.
  • they serialize the requests and responses into messages and deserialize messages back into requests and responses.


Dispatching performs the actual method calling determining with method to call and how to pass it the parameters. The result of the method call, or the exception if the call failed is assembled and made available to the protocol for serialization.

Client and Server

The client and server classes tie all components together to provide the application interface.