def add_call(self, procedure, num_output, args, kwargs, code_type, new_code=None): """Override function of Worker class. If it is the first execution set all intern attributes and run the execution. Else call the Worker function. Arguments: - procedure: name of the function to be executed. - num_output: number of outputs of the function. - args: arguments used in the call of the function. - kwargs: key arguments used in the call of the function. - code_type: Type of the MultiCode used. - new_code: Code of the created task. If is None code will be computed. """ if not self.running: return self.run(procedure, args, kwargs) else: try: return Worker.add_call(self, procedure, num_output, args, kwargs, code_type, new_code) except TypeError: raise TypeError("Error in %s adding call to function %s" % (self.procedure.name, procedure))
def __init__(self, display=False, code='0', mongodb_name=''): zmq_transport = 'inproc' io_threads = 1 tornado_sockets = True group_id = '0' self.running = False self.init_code = code db_num = 1 context = None Worker.__init__(self, zmq_transport, tornado_sockets, display, context, io_threads, db_num, group_id) self.result_class = DevResult from pyople.tasks.models import MultiprocessTask self.mongodb_name = mongodb_name self.connect_mongodb(mongodb_name) MultiprocessTask.set_environment(self)