def _task_failed_to_schedule(self, task, task_collection, exception): # log error msg = ("Failed to schedule task. Trace: \n%s" % traceback.format_exc()) logger.error(msg) logger.error(traceback.format_exc()) # set state to failed task.state = State.FAILED # bump up try count task.try_count += 1 set_task_retry_info(task, exception) error_code = to_mbs_error_code(exception) if not task.id: task.log_event(event_type=EventType.ERROR, message=msg, error_code=error_code) else: tc = task_collection tc.update_task(task, properties=["state", "tryCount", "nextRetryDate", "finalRetryDate"], event_name="FAILED_TO_SCHEDULE", details=msg, error_code=error_code, event_type=EventType.ERROR)
def worker_fail(self, exception, trace=None): if isinstance(exception, MBSError): log_msg = exception.message else: log_msg = "Unexpected error. Please contact admin" details = safe_stringify(exception) task = self._task self.get_task_collection().update_task( task, event_type=EventType.ERROR, message=log_msg, details=details, error_code=to_mbs_error_code(exception)) # update retry info set_task_retry_info(task, exception) self.worker_finished(State.FAILED) # send a notification only if the task is not reschedulable # if there is an event queue configured then do not notify (because it should be handled by the backup # event listener) if not get_mbs().event_queue and task.exceeded_max_tries(): get_mbs().notifications.notify_on_task_failure( task, exception, trace)
def worker_fail(self, exception, trace=None): if isinstance(exception, MBSError): log_msg = exception.message else: log_msg = "Unexpected error. Please contact admin" details = safe_stringify(exception) task = self._task self.get_task_collection().update_task( task, event_type=EventType.ERROR, message=log_msg, details=details, error_code=to_mbs_error_code(exception)) # update retry info set_task_retry_info(task, exception) self.worker_finished(State.FAILED) # send a notification only if the task is not reschedulable # if there is an event queue configured then do not notify (because it should be handled by the backup # event listener) if not get_mbs().event_queue and task.exceeded_max_tries(): get_mbs().notifications.notify_on_task_failure(task, exception, trace)