Toto 1.0.10 documentation


«  Workers and Connections   ::   Contents   ::   WorkerConnection  »


class toto.worker.TotoWorkerService(conf_file=None, **kwargs)[source]

Instances can be configured in three ways:

  1. (Most common) Pass the path to a config file as the first parameter to the constructor.
  2. Pass config parameters as command line arguments to the initialization script.
  3. Pass keyword arguments to the constructor.

Precidence is as follows:

Keyword args, config file, command line

The following method will normally be your only interaction with an instance of TotoWorkerService[source]


class toto.worker.TotoWorker(method_module, socket_address, db_connection, compression=None, serialization=None)[source]

The worker is responsible for processing all RPC calls. An instance will be initialized for each incoming request.

You can set the module to use for method delegation via the method_module parameter. Methods are modules that contain an invoke function:

def invoke(handler, parameters)

The request worker instance will be passed as the first parameter to the invoke function and provides access to the server’s database connection. Request parameters will be passed as the second argument to the invoke function.

Any value returned from a method invocation will be sent to the caller, closing the message->response cycle. If you only need to let the caller know that the task has begun, you should decorate your invoke function with @toto.invocation.asynchronous to send a response before processing begins.

«  Workers and Connections   ::   Contents   ::   WorkerConnection  »