diff --git a/passbook/core/tasks.py b/passbook/core/tasks.py index 01fd1e1d4..34aa6fb5c 100644 --- a/passbook/core/tasks.py +++ b/passbook/core/tasks.py @@ -37,6 +37,7 @@ def clean_expired_models(self: MonitoredTask): @CELERY_APP.task(bind=True, base=MonitoredTask) def backup_database(self: MonitoredTask): # pragma: no cover """Database backup""" + self.result_timeout_hours = 25 try: start = datetime.now() out = StringIO() diff --git a/passbook/lib/tasks.py b/passbook/lib/tasks.py index ff7fbab7c..eb9aff13c 100644 --- a/passbook/lib/tasks.py +++ b/passbook/lib/tasks.py @@ -66,13 +66,13 @@ class TaskInfo: """Delete task info from cache""" return cache.delete(f"task_{self.task_name}") - def save(self): + def save(self, timeout_hours=6): """Save task into cache""" key = f"task_{self.task_name}" if self.result.uid: key += f"_{self.result.uid}" self.task_name += f"_{self.result.uid}" - cache.set(key, self, timeout=13 * 60 * 60) + cache.set(key, self, timeout=timeout_hours * 60 * 60) class MonitoredTask(Task): @@ -90,6 +90,7 @@ class MonitoredTask(Task): self.save_on_success = True self._uid = None self._result = TaskResult(status=TaskResultStatus.ERROR, messages=[]) + self.result_timeout_hours = 6 def set_uid(self, uid: str): """Set UID, so in the case of an unexpected error its saved correctly""" @@ -115,7 +116,7 @@ class MonitoredTask(Task): task_call_func=self.__name__, task_call_args=args, task_call_kwargs=kwargs, - ).save() + ).save(self.result_timeout_hours) return super().after_return(status, retval, task_id, args, kwargs, einfo=einfo) # pylint: disable=too-many-arguments @@ -131,7 +132,7 @@ class MonitoredTask(Task): task_call_func=self.__name__, task_call_args=args, task_call_kwargs=kwargs, - ).save() + ).save(self.result_timeout_hours) return super().on_failure(exc, task_id, args, kwargs, einfo=einfo) def run(self, *args, **kwargs): diff --git a/passbook/root/settings.py b/passbook/root/settings.py index cd3b8ef8c..279a18343 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -322,7 +322,7 @@ if not DEBUG and _ERROR_REPORTING: ], before_send=before_send, release="passbook@%s" % __version__, - traces_sample_rate=1.0, + traces_sample_rate=0.6, environment=CONFIG.y("error_reporting.environment", "customer"), send_default_pii=CONFIG.y_bool("error_reporting.send_pii", False), )