Skip to content

Commit

Permalink
Fix for the race condition with updating credible regions on localiza…
Browse files Browse the repository at this point in the history
…tion creation
  • Loading branch information
Jon committed Feb 27, 2023
1 parent 0c613d4 commit 34ee175
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tom_nonlocalizedevents/signals/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from functools import partial

from django.dispatch import receiver
from django.db.models.signals import post_save
from django.db import transaction

from tom_nonlocalizedevents.models import EventCandidate, EventLocalization
from tom_nonlocalizedevents.healpix_utils import update_all_credible_region_percents_for_candidates
Expand All @@ -24,4 +27,6 @@ def cb_post_save_event_localization(sender, instance, created, **kwargs):
# Anytime a new EventLocalization is created, update the smallest probability credible region for each
# EventCandidate associated with that nonlocalizedevent for the new localization
if created:
update_all_credible_region_percents_for_candidates(instance)
transaction.on_commit(
partial(update_all_credible_region_percents_for_candidates, event_localization=instance)
)

0 comments on commit 34ee175

Please sign in to comment.