send inv computed tasks *after* commit to avoid a race condition

This commit is contained in:
Ryan Petrello
2020-01-15 00:08:30 -05:00
parent be68a199ec
commit 0f0d9ba00d
5 changed files with 27 additions and 21 deletions

View File

@@ -10,6 +10,7 @@ import pkg_resources
import sys
# Django
from django.db import connection
from django.conf import settings
from django.db.models.signals import (
pre_save,
@@ -124,7 +125,9 @@ def emit_update_inventory_on_created_or_deleted(sender, **kwargs):
pass
else:
if inventory is not None:
update_inventory_computed_fields.delay(inventory.id)
connection.on_commit(
lambda: update_inventory_computed_fields.delay(inventory.id)
)
def rebuild_role_ancestor_list(reverse, model, instance, pk_set, action, **kwargs):