<s> import toto <EOL> import cPickle as pickle <EOL> import zlib <EOL> import logging <EOL> from threading import Thread <EOL> from tornado . options import options <EOL> from tornado . gen import Task <EOL> from collections import deque <EOL> from time import time <EOL> from uuid import uuid4 <EOL> from traceback import format_exc <EOL> from toto . options import safe_define <EOL> safe_define ( "<STR_LIT>" , type = str , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , type = str , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , type = str , default = '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , default = <NUM_LIT> , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , default = False , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , default = <NUM_LIT:0> , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , default = '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> safe_define ( "<STR_LIT>" , default = '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> WORKER_SOCKET_CONNECT = '<STR_LIT>' <EOL> WORKER_SOCKET_DISCONNECT = '<STR_LIT>' <EOL> class WorkerConnection ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __getattr__ ( self , path ) : <EOL> return WorkerInvocation ( path , self ) <EOL> def log_error ( self , error ) : <EOL> logging . error ( repr ( error ) ) <EOL> def enable_traceback_logging ( self ) : <EOL> from new import instancemethod <EOL> from traceback import format_exc <EOL> def log_error ( self , e ) : <EOL> logging . error ( format_exc ( ) ) <EOL> self . log_error = instancemethod ( log_error , self ) <EOL> @ classmethod <EOL> def instance ( cls ) : <EOL> '''<STR_LIT>''' <EOL> if not hasattr ( cls , '<STR_LIT>' ) : <EOL> if options . worker_transport == '<STR_LIT:http>' : <EOL> from toto . httpworkerconnection import HTTPWorkerConnection <EOL> cls . _instance = HTTPWorkerConnection . instance ( ) <EOL> else : <EOL> from toto . zmqworkerconnection import ZMQWorkerConnection <EOL> cls . _instance = ZMQWorkerConnection . instance ( ) <EOL> return cls . _instance <EOL> class WorkerInvocation ( object ) : <EOL> def __init__ ( self , path , connection ) : <EOL> self . _path = path <EOL> self . _connection = connection <EOL> def __call__ ( self , * args , ** kwargs ) : <EOL> return self . _connection . invoke ( self . _path , * args , ** kwargs ) <EOL> def __getattr__ ( self , path ) : <EOL> return getattr ( self . _connection , self . _path + '<STR_LIT:.>' + path ) </s>
