Module Expr Str Import alias Import alias ImportFrom alias Import alias ImportFrom alias Import alias Import alias Import alias identifier Import alias Import alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias Expr Call NameLoad Str keyword Str keyword Str Expr Call NameLoad Str keyword NameLoad keyword Str keyword NameLoad Expr Call NameLoad Str keyword NameLoad keyword NameLoad keyword Str Expr Call NameLoad Str keyword NameLoad keyword NameLoad keyword Str Expr Call NameLoad Str keyword Str keyword Str Expr Call NameLoad Str keyword Str keyword Str Expr Call NameLoad Str keyword Str keyword Str Expr Call NameLoad Str keyword NameLoad keyword Str keyword Str Expr Call NameLoad Str keyword NameLoad keyword Str Expr Call NameLoad Str keyword NameLoad keyword Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad kwarg body Assign NameStore Set Str Str Assign NameStore Set Str Assign TupleStore NameStore AttributeStore NameLoad attr TupleLoad AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareIn SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr Str attr Str Index Num NameLoad Expr Call AttributeLoad NameLoad attr NameLoad DictComp NameLoad SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad CompareIn NameLoad NameLoad Assign NameStore SetComp Call NameLoad NameLoad NameLoad comprehension NameStore NameLoad Call NameLoad NameLoad NameLoad For NameStore NameLoad body Expr Call NameLoad NameLoad Assign NameStore SetComp SubscriptLoad Call AttributeLoad Call NameLoad NameLoad NameLoad attr Str Num Index Num comprehension NameStore NameLoad Call NameLoad NameLoad NameLoad For NameStore NameLoad body Expr Call NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad For NameStore NameLoad body For NameStore GeneratorExp NameLoad comprehension NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad For NameStore NameLoad body For NameStore GeneratorExp NameLoad comprehension NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad Assign TupleStore NameStore AttributeStore AttributeLoad NameLoad attr attr TupleLoad AttributeLoad AttributeLoad NameLoad attr attr Lambda arguments args defaults vararg kwarg NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr NameLoad If AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr If AttributeLoad NameLoad attr body With Call NameLoad Call NameLoad Num Str NameStore body Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assign NameStore IfExp CompareGtE AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr Call NameLoad If CompareEq NameLoad Num body Print BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Print BinOpMod Str TupleLoad NameLoad BoolOpOr BoolOpAnd CompareGt NameLoad Num Str Str BoolOpOr BoolOpAnd AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad If AttributeLoad NameLoad attr body ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body For NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BoolOpOr BoolOpAnd AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore BoolOpAnd AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Expr Call SubscriptLoad AttributeLoad Call NameLoad SubscriptLoad NameLoad Index Num attr Index SubscriptLoad NameLoad Index Num keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Print BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr decorator_list decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd NameLoad AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd NameLoad AttributeLoad NameLoad attr Lambda arguments args NameParam defaults NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd NameLoad AttributeLoad NameLoad attr Lambda arguments args NameParam defaults NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body ImportFrom alias FunctionDef arguments args NameParam NameParam defaults body If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad Call NameLoad Return AttributeLoad NameLoad attr decorator_list Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults AttributeLoad NameLoad attr body FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad While AttributeLoad NameLoad attr body TryExcept body Assign NameStore SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr attr Str Num Index Num Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad If CompareEq NameLoad Str body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Return orelse If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list If NameLoad body Assign NameStore Call NameLoad keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore NameLoad While AttributeLoad NameLoad attr body TryExcept body Assign AttributeStore NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad SubscriptLoad NameLoad Index Str Assign NameStore AttributeLoad NameLoad attr For NameStore Call AttributeLoad SubscriptLoad NameLoad Index Str attr Str body Assign NameStore Call NameLoad NameLoad NameLoad If Call NameLoad AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad Assign NameStore NameLoad Assign AttributeStore NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad Index Str orelse Assign AttributeStore NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad handlers ExceptHandler type NameLoad name NameStore body If NameLoad body Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Dict Str Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Str Expr Call AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A The Toto worker and worker connection classes are designed to help build RPC systems,
allowing you to pass CPU intensive work to other processeses or machines. Workers
were originally designed for use with the Toto server, making it easy to perform
long running tasks without effecting the server's responsiveness, but they have been
designed to be used independently and have no direct ties to the web server
architecture.

``TotoWorkers`` and ``WorkerConnections`` use ZMQ for messaging and require the ``pyzmq`` module.

The ``TotoWorkerService`` has a built in message router that will round-robin balance incoming
messages. The router can be disabled through configuration if only one worker process is needed.
Alternatively, the router can be configured to run without any worker processes, allowing multiple
machines to share a common router.

Most of the time you'll only need this script to start your server::

  from toto.worker import TotoWorkerService
  
  TotoWorkerService('settings.conf').run()

Methods, startup functions and databases can all be configured with the conf file.

Run your startup script with --help to see all available options.
 N/A os N/A zmq zmq.devices.basedevice ProcessDevice N/A tornado tornado.options options N/A logging N/A zlib N/A cPickle pickle N/A sys N/A time threading Thread multiprocessing Process cpu_count toto.service TotoService process_count pid_path toto.dbconnection configured_connection exceptions * toto.options safe_define N/A N/A safe_define method_module default methods help The root module to use for method lookup N/A N/A safe_define remote_event_receivers type str help A comma separated list of remote event address that this event manager should connect to. e.g.: 'tcp://192.168.1.2:8889' multiple True N/A N/A safe_define event_init_module default None type str help If defined, this module's 'invoke' function will be called with the EventManager instance after the main event handler is registered (e.g.: myevents.setup) N/A N/A safe_define startup_function default None type str help An optional function to run on startup - e.g. module.function. The function will be called for each worker process after it is configured and before it starts listening for tasks with the named parameters worker and db_connection. N/A N/A safe_define worker_bind_address default tcp://*:55555 help The service will bind to this address with a zmq PULL socket and listen for incoming tasks. Tasks will be load balanced to all workers. If this is set to an empty string, workers will connect directly to worker_socket_address. N/A N/A safe_define worker_socket_address default ipc:///tmp/workerservice.sock help The load balancer will use this address to coordinate tasks between local workers N/A N/A safe_define control_socket_address default ipc:///tmp/workercontrol.sock help Workers will subscribe to messages on this socket and listen for control commands. If this is an empty string, the command option will have no effect N/A N/A safe_define command type str metavar status|shutdown help Specify a command to send to running workers on the control socket N/A N/A safe_define compression_module type str help The module to use for compressing and decompressing messages. The module must have 'decompress' and 'compress' methods. If not specified, no compression will be used. You can also set worker.compress and worker.decompress in your startup method for increased flexibility N/A N/A safe_define serialization_module type str help The module to use for serializing and deserializing messages. The module must have 'dumps' and 'loads' methods. If not specified, cPickle will be used. You can also set worker.dumps and worker.loads in your startup method for increased flexibility TotoWorkerService N/A TotoService N/A N/A 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
   __init__ N/A N/A self conf_file N/A None kwargs N/A N/A module_options N/A method_module event_init_module N/A function_options N/A startup_function N/A N/A original_argv N/A sys argv N/A N/A sys argv N/A i N/A i N/A sys argv N/A N/A N/A N/A N/A N/A i strip - split = N/A 0 module_options N/A N/A N/A self _load_options conf_file N/A i N/A kwargs N/A i N/A i kwargs N/A i module_options N/A modules N/A N/A getattr options i N/A i module_options N/A getattr options i N/A module modules N/A N/A N/A __import__ module N/A function_modules N/A N/A N/A N/A N/A getattr options i rsplit . 1 N/A 0 N/A i function_options N/A getattr options i N/A module function_modules N/A N/A N/A __import__ module N/A N/A sys argv original_argv N/A N/A N/A N/A super TotoWorkerService self __init__ conf_file kwargs N/A module modules N/A N/A i N/A m N/A m N/A N/A N/A sys modules keys N/A N/A m startswith module N/A N/A N/A N/A sys modules N/A i N/A module function_modules N/A N/A i N/A m N/A m N/A N/A N/A sys modules keys N/A N/A m startswith module N/A N/A N/A N/A sys modules N/A i N/A N/A define N/A N/A tornado options define N/A N/A N/A tornado options define N/A N/A N/A N/A args kwargs None N/A N/A self __event_init N/A N/A N/A options event_init_module N/A __import__ N/A options event_init_module None N/A N/A self __method_module N/A N/A N/A options method_module N/A __import__ N/A options method_module None N/A N/A N/A tornado options define define N/A prepare N/A N/A self N/A N/A N/A N/A self balancer None N/A N/A options worker_bind_address N/A N/A N/A self balancer N/A ProcessDevice N/A zmq QUEUE N/A zmq ROUTER N/A zmq DEALER N/A N/A N/A self balancer daemon True N/A N/A N/A N/A self balancer bind_in N/A options worker_bind_address N/A N/A N/A N/A self balancer bind_out N/A options worker_socket_address N/A N/A N/A N/A self balancer setsockopt_in N/A zmq IDENTITY ROUTER N/A N/A N/A N/A self balancer setsockopt_out N/A zmq IDENTITY DEALER N/A N/A N/A N/A self balancer start N/A N/A options daemon N/A N/A N/A open N/A pid_path 0 wb f N/A N/A N/A N/A f write N/A str N/A N/A N/A self balancer launcher pid N/A count N/A N/A N/A options processes 0 N/A options processes N/A cpu_count N/A N/A count 0 N/A N/A N/A Starting load balancer. Listening on "%s". Routing to "%s" N/A N/A options worker_bind_address N/A options worker_socket_address N/A N/A N/A Starting %s worker process%s. %s. N/A count N/A N/A N/A count 1 es N/A N/A N/A options worker_bind_address N/A Listening on "%s" N/A options worker_bind_address N/A Connecting to "%s" N/A options worker_socket_address N/A main_loop N/A N/A self N/A N/A N/A db_connection N/A configured_connection N/A N/A options remote_event_receivers N/A toto.events EventManager N/A event_manager N/A N/A EventManager instance N/A N/A options remote_instances N/A N/A address N/A N/A N/A options remote_event_receivers split , N/A N/A N/A N/A event_manager register_server address N/A init_module N/A self __event_init N/A init_module N/A N/A N/A N/A init_module invoke event_manager N/A serialization N/A N/A N/A options serialization_module N/A __import__ N/A options serialization_module pickle N/A compression N/A N/A options compression_module N/A __import__ N/A options compression_module N/A worker N/A TotoWorker N/A self __method_module N/A options worker_socket_address db_connection compression serialization N/A N/A options startup_function N/A N/A startup_path N/A N/A N/A options startup_function rsplit . N/A N/A N/A N/A N/A __import__ N/A startup_path N/A 0 __dict__ N/A N/A startup_path N/A 1 worker worker db_connection db_connection N/A N/A N/A worker start N/A send_worker_command N/A N/A self command N/A N/A N/A N/A options control_socket_address N/A N/A socket N/A N/A N/A N/A zmq Context socket N/A zmq PUB N/A N/A N/A socket bind N/A options control_socket_address N/A N/A N/A time sleep 1 N/A N/A N/A socket send_string N/A command %s command N/A N/A Sent command: %s N/A options command N/A run N/A N/A self N/A N/A N/A N/A options command N/A N/A N/A N/A self send_worker_command N/A options command N/A N/A N/A N/A N/A super TotoWorkerService self run N/A N/A TotoWorker N/A N/A N/A 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.
   __init__ N/A N/A self method_module socket_address db_connection compression serialization N/A None None N/A N/A N/A self context N/A N/A zmq Context N/A N/A self socket_address socket_address N/A N/A self method_module method_module N/A N/A self db_connection db_connection N/A N/A self db N/A N/A db_connection N/A db_connection db None N/A N/A self status Initialized N/A N/A self running False N/A N/A self compress N/A N/A compression N/A compression compress N/A N/A N/A x N/A x N/A N/A self decompress N/A N/A compression N/A compression decompress N/A N/A N/A x N/A x N/A N/A self loads N/A N/A serialization N/A serialization loads N/A pickle loads N/A N/A self dumps N/A N/A serialization N/A serialization dumps N/A pickle dumps N/A N/A options debug N/A traceback format_exc error_info N/A N/A self e N/A N/A N/A N/A N/A isinstance e TotoException N/A N/A e N/A TotoException ERROR_SERVER N/A str e N/A N/A N/A logging error N/A %s
%s
 N/A e N/A format_exc N/A N/A e __dict__ N/A N/A N/A TotoWorker error_info error_info N/A error_info N/A N/A self e N/A N/A N/A N/A N/A isinstance e TotoException N/A N/A e N/A TotoException ERROR_SERVER N/A str e N/A N/A N/A logging error N/A str e N/A N/A e __dict__ N/A log_status N/A N/A self N/A N/A N/A N/A N/A logging info N/A Pid: %s status: %s N/A N/A N/A os getpid N/A self status N/A __monitor_control N/A N/A self address N/A N/A options control_socket_address N/A monitor N/A N/A N/A N/A N/A socket N/A N/A N/A self context socket N/A zmq SUB N/A N/A N/A socket setsockopt N/A zmq SUBSCRIBE command N/A N/A N/A socket connect address N/A N/A self running N/A N/A N/A N/A command N/A N/A N/A N/A N/A socket recv split 1 N/A 1 N/A N/A N/A logging info N/A Received command: %s command N/A N/A command shutdown N/A N/A N/A self running False N/A N/A N/A N/A self context term N/A N/A N/A N/A command status N/A N/A N/A N/A self log_status N/A N/A N/A Exception N/A e N/A N/A N/A N/A self error_info e N/A N/A address N/A N/A thread N/A Thread target monitor N/A N/A thread daemon True N/A N/A N/A thread start N/A start N/A N/A self N/A N/A N/A N/A self running True N/A N/A N/A self __monitor_control N/A socket N/A N/A N/A self context socket N/A zmq REP N/A N/A N/A socket connect N/A self socket_address N/A pending_reply False N/A N/A self running N/A N/A N/A N/A N/A self status Listening N/A message N/A N/A socket recv_multipart N/A pending_reply True N/A message_id N/A message N/A 0 N/A data N/A N/A self loads N/A N/A self decompress N/A message N/A 1 N/A N/A N/A logging info N/A Received Task %s: %s N/A message_id N/A data N/A method N/A method N/A self method_module N/A i N/A N/A N/A data N/A method split . N/A N/A method N/A getattr method i N/A N/A hasattr N/A method invoke asynchronous N/A N/A N/A N/A socket send_multipart N/A message_id N/A pending_reply False N/A N/A self status Working N/A N/A N/A method invoke self N/A data N/A parameters N/A N/A N/A self status Working N/A response N/A N/A method invoke self N/A data N/A parameters N/A N/A N/A socket send_multipart N/A message_id N/A N/A self compress N/A N/A self dumps response N/A pending_reply False N/A N/A N/A Exception N/A e N/A N/A pending_reply N/A N/A N/A N/A socket send_multipart N/A message_id N/A N/A self compress N/A N/A self dumps N/A error N/A N/A self error_info e N/A N/A self status Finished N/A N/A N/A self log_status N/A N/A