示例#1
0
 def _send_message(self, type, exception=None):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.connect(('localhost', self.port))
     try:
         _send_message(sock, {
             'type': type,
             'task_id': self.task_id,
             'exception': exceptions.wrap_if_needed(exception),
             'traceback': exceptions.get_exception_as_string(*sys.exc_info()),
         })
         response = _recv_message(sock)
         response_exception = response.get('exception')
         if response_exception:
             raise response_exception
     finally:
         sock.close()
示例#2
0
 def _processor(self):
     while not self._stopped:
         try:
             task = self._queue.get(timeout=1)
             self._task_started(task)
             try:
                 task_func = imports.load_attribute(task.function)
                 arguments = dict(arg.unwrapped for arg in task.arguments.values())
                 task_func(ctx=task.context, **arguments)
                 self._task_succeeded(task)
             except BaseException as e:
                 self._task_failed(task,
                                   exception=e,
                                   traceback=exceptions.get_exception_as_string(*sys.exc_info()))
         # Daemon threads
         except BaseException as e:
             pass