def worker(worker_id, pool_id, task_queue, result_queue, worker_queue):
start_file_logger('<STR_LIT>'.format(args.logdir, pool_id, worker_id),<EOL>worker_id,<EOL>name="<STR_LIT>",<EOL>level=logging.DEBUG if args.debug else logging.INFO)<EOL>logger.info('<STR_LIT>'.format(worker_id))<EOL>if args.debug:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL><DEDENT>while True:<EOL><INDENT>worker_queue.put(worker_id)<EOL>req = task_queue.get()<EOL>tid = req['<STR_LIT>']<EOL>logger.info("<STR_LIT>".format(tid))<EOL>try:<EOL><INDENT>worker_queue.get()<EOL><DEDENT>except queue.Empty:<EOL><INDENT>logger.warning("<STR_LIT>".format(worker_id))<EOL>pass<EOL><DEDENT>try:<EOL><INDENT>result = execute_task(req['<STR_LIT>'])<EOL>serialized_result = serialize_object(result)<EOL><DEDENT>except Exception:<EOL><INDENT>result_package = {'<STR_LIT>': tid, '<STR_LIT>': serialize_object(RemoteExceptionWrapper(*sys.exc_info()))}<EOL><DEDENT>else:<EOL><INDENT>result_package = {'<STR_LIT>': tid, '<STR_LIT:result>': serialized_result}<EOL><DEDENT>logger.info("<STR_LIT>".format(tid))<EOL>pkl_package = pickle.dumps(result_package)<EOL>result_queue.put(pkl_package)<EOL><DEDENT>
Put request token into queue
Get task from task_queue
Pop request from queue
Put result into result_queue