Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/task.py
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | def __call__(self, *args, **kwargs): | ||||
self.statsd.gauge("swh_task_end_ts", ts(), tags={"status": status}) | self.statsd.gauge("swh_task_end_ts", ts(), tags={"status": status}) | ||||
return result | return result | ||||
def on_failure(self, exc, task_id, args, kwargs, einfo): | def on_failure(self, exc, task_id, args, kwargs, einfo): | ||||
self.statsd.increment("swh_task_failure_count") | self.statsd.increment("swh_task_failure_count") | ||||
def on_success(self, retval, task_id, args, kwargs): | def on_success(self, retval, task_id, args, kwargs): | ||||
self.statsd.increment("swh_task_success_count") | self.statsd.increment("swh_task_success_count") | ||||
# this is a swh specific event. Used to attach the retval to the | |||||
# task_run | # Respecting the configuration per task | ||||
if not self.ignore_result: | |||||
# we send the swh specific event used to attach the retval to the task_run. | |||||
# The listener is in charge of processing the event | |||||
self.send_event("task-result", result=retval) | self.send_event("task-result", result=retval) | ||||
@property | @property | ||||
def log(self): | def log(self): | ||||
if self._log is None: | if self._log is None: | ||||
self._log = get_task_logger(self.name) | self._log = get_task_logger(self.name) | ||||
return self._log | return self._log | ||||
def run(self, *args, **kwargs): | def run(self, *args, **kwargs): | ||||
self.log.debug("%s: args=%s, kwargs=%s", self.name, args, kwargs) | self.log.debug("%s: args=%s, kwargs=%s", self.name, args, kwargs) | ||||
ret = super().run(*args, **kwargs) | ret = super().run(*args, **kwargs) | ||||
self.log.debug("%s: OK => %s", self.name, ret) | self.log.debug("%s: OK => %s", self.name, ret) | ||||
return ret | return ret |