From 1842e3dd9bd5dd746eddc4d7a3f2a3afcc7da8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 22 Jul 2016 12:21:09 +0200 Subject: [PATCH] Fix race condition on item creations and timeline inclusion --- taiga/timeline/signals.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/taiga/timeline/signals.py b/taiga/timeline/signals.py index 9fc601da..1bee6c27 100644 --- a/taiga/timeline/signals.py +++ b/taiga/timeline/signals.py @@ -21,6 +21,7 @@ from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.utils import timezone from django.utils.translation import ugettext as _ +from django.db import connection from taiga.projects.history import services as history_services from taiga.projects.history.choices import HistoryType @@ -35,7 +36,7 @@ def _push_to_timelines(project, user, obj, event_type, created_datetime, extra_d ct = ContentType.objects.get_for_model(obj) if settings.CELERY_ENABLED: - push_to_timelines.delay(project_id, user.id, ct.app_label, ct.model, obj.id, event_type, created_datetime, extra_data=extra_data) + connection.on_commit(lambda: push_to_timelines.delay(project_id, user.id, ct.app_label, ct.model, obj.id, event_type, created_datetime, extra_data=extra_data)) else: push_to_timelines(project_id, user.id, ct.app_label, ct.model, obj.id, event_type, created_datetime, extra_data=extra_data)