def move(self): try: task = self.ready_queue.get(timeout=1.0) except Empty: return if task.revoked(): return self.logger.debug("Mediator: Running callback for task: %s[%s]" % (task.task_name, task.task_id)) try: self.callback(task) except Exception, exc: log_with_extra(self.logger, logging.ERROR, "Mediator callback raised exception %r\n%s" % (exc, traceback.format_exc()), exc_info=sys.exc_info(), extra={ "data": { "hostname": task.hostname, "id": task.task_id, "name": task.task_name } })
def on_failure(self, exc_info): """Handler called if the task raised an exception.""" state.task_ready(self) if self.task.acks_late: self.acknowledge() if isinstance(exc_info.exception, RetryTaskError): return self.on_retry(exc_info) # This is a special case as the process would not have had # time to write the result. if isinstance(exc_info.exception, WorkerLostError): if self._store_errors: self.task.backend.mark_as_failure(self.task_id, exc_info.exception) self.send_event("task-failed", uuid=self.task_id, exception=safe_repr(exc_info.exception), traceback=safe_str(exc_info.traceback)) context = { "hostname": self.hostname, "id": self.task_id, "name": self.task_name, "exc": safe_repr(exc_info.exception), "traceback": safe_str(exc_info.traceback), "args": self.args, "kwargs": self.kwargs } log_with_extra(self.logger, logging.ERROR, self.error_msg.strip() % context, exc_info=exc_info, extra={ "data": { "hostname": self.hostname, "id": self.task_id, "name": self.task_name } }) task_obj = tasks.get(self.task_name, object) self.send_error_email(task_obj, context, exc_info.exception, enabled=task_obj.send_error_emails, whitelist=task_obj.error_whitelist)
def on_failure(self, exc_info): """Handler called if the task raised an exception.""" state.task_ready(self) if self.task.acks_late: self.acknowledge() if isinstance(exc_info.exception, RetryTaskError): return self.on_retry(exc_info) # This is a special case as the process would not have had # time to write the result. if isinstance(exc_info.exception, WorkerLostError): if self._store_errors: self.task.backend.mark_as_failure(self.task_id, exc_info.exception) self.send_event("task-failed", uuid=self.task_id, exception=repr(exc_info.exception), traceback=exc_info.traceback) context = {"hostname": self.hostname, "id": self.task_id, "name": self.task_name, "exc": repr(exc_info.exception), "traceback": unicode(exc_info.traceback, sys.getfilesystemencoding()), "args": self.args, "kwargs": self.kwargs} log_with_extra(self.logger, logging.ERROR, self.error_msg.strip() % context, exc_info=exc_info, extra={"data": {"hostname": self.hostname, "id": self.task_id, "name": self.task_name}}) task_obj = tasks.get(self.task_name, object) self.send_error_email(task_obj, context, exc_info.exception, enabled=task_obj.send_error_emails, whitelist=task_obj.error_whitelist)
def move(self): try: task = self.ready_queue.get(timeout=1.0) except Empty: return if task.revoked(): return self.logger.debug("Mediator: Running callback for task: %s[%s]" % (task.task_name, task.task_id)) try: self.callback(task) except Exception, exc: log_with_extra( self.logger, logging.ERROR, "Mediator callback raised exception %r\n%s" % (exc, traceback.format_exc()), exc_info=sys.exc_info(), extra={"data": {"hostname": task.hostname, "id": task.task_id, "name": task.task_name}}, )