Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Make task's expiration date (time limit) configurable

Marcin Wcislo795e35a986dd
diff --git a/saleor/core/tasks.py b/saleor/core/tasks.py
index ece786fdb3..1f137c220f 100644
--- a/saleor/core/tasks.py
+++ b/saleor/core/tasks.py
@@ -26,7 +26,10 @@ def delete_from_storage_task(path):
@app.task
def delete_event_payloads_task(expiration_date=None):
- expiration_date = expiration_date or timezone.now() + datetime.timedelta(minutes=60)
+ expiration_date = (
+ expiration_date
+ or timezone.now() + settings.EVENT_PAYLOAD_DELETE_TASK_TIME_LIMIT
+ )
delete_period = timezone.now() - settings.EVENT_PAYLOAD_DELETE_PERIOD
valid_deliveries = EventDelivery.objects.filter(created_at__gt=delete_period)
payloads_to_delete = EventPayload.objects.filter(
@@ -39,7 +42,7 @@ def delete_event_payloads_task(expiration_date=None):
qs.delete()
delete_event_payloads_task.delay(expiration_date)
else:
- task_logger.warning("Task invocation time limit reached, aborting task")
+ task_logger.error("Task invocation time limit reached, aborting task")
@app.task(
diff --git a/saleor/settings.py b/saleor/settings.py
index f11abd02e3..f63bc01a7b 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -637,6 +637,9 @@ CELERY_BEAT_MAX_LOOP_INTERVAL = 300 # 5 minutes
EVENT_PAYLOAD_DELETE_PERIOD = timedelta(
seconds=parse(os.environ.get("EVENT_PAYLOAD_DELETE_PERIOD", "14 days"))
)
+EVENT_PAYLOAD_DELETE_TASK_TIME_LIMIT = timedelta(
+ seconds=parse(os.environ.get("EVENT_PAYLOAD_DELETE_TASK_TIME_LIMIT", "1 hour"))
+)
# Time between marking app "to remove" and removing the app from the database.
# App is not visible for the user after removing, but it still exists in the database.
# Saleor needs time to process sending `APP_DELETED` webhook and possible retrying,