Skip to content
Snippets Groups Projects
Commit c1a2e1c5 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch 'issue-345' into 'master'

Delay all celery task creations to on_commit

Closes #345

See merge request !434
parents e9923d88 feca4d58
No related branches found
No related tags found
1 merge request!434Delay all celery task creations to on_commit
Pipeline #5201 passed
......@@ -494,7 +494,7 @@ class Notification(ExtensibleModel, TimeStampedModel):
def save(self, **kwargs):
super().save(**kwargs)
if not self.sent:
transaction.on_commit(lambda: send_notification(self.pk, resend=True))
send_notification(self.pk, resend=True)
self.sent = True
super().save(**kwargs)
......
......@@ -14,6 +14,7 @@ else:
import importlib_metadata as metadata
from django.conf import settings
from django.db import transaction
from django.db.models import Model, QuerySet
from django.http import HttpRequest
from django.shortcuts import get_object_or_404
......@@ -209,7 +210,7 @@ def celery_optional(orig: Callable) -> Callable:
def wrapped(*args, **kwargs):
if is_celery_enabled():
return task.delay(*args, **kwargs), False
return transaction.on_commit(lambda: task.delay(*args, **kwargs)), False
else:
return orig(*args, **kwargs), True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment