Skip to content

Commit

Permalink
fix: avoid call Routine's async flow before updating on db
Browse files Browse the repository at this point in the history
After updating a Routine some tasks are trigered async. This commit changes the callback which trigger that to
be performed on `post_save` instead of `pre_save`
  • Loading branch information
Hudson Medeiros authored and lucasgomide committed Jun 7, 2023
1 parent 057dcfe commit 63ceb47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django_cloud_tasks/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.exceptions import ValidationError
from django.db.models.signals import pre_save
from django.db.models import Model
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver

from django_cloud_tasks import models
Expand Down Expand Up @@ -40,7 +41,7 @@ def enqueue_revert_task(instance: models.Routine):
}


@receiver(pre_save, sender=models.Routine)
@receiver(post_save, sender=models.Routine)
def handle_status_changed(sender, instance: models.Routine, **kwargs):
if not _is_status_changing(instance=instance):
return
Expand Down

0 comments on commit 63ceb47

Please sign in to comment.