When ATOMIC_REQUESTS=True is set, are ORM signals - post_save and pre_save - also executed within the transaction? Per my inference, they seem be to a part of the transaction.

Assuming my inference is correct, then consider the following code


@receiver(post_save, sender=MyModel)
def log_and_notify_change(sender, instance, created, **kwargs):
    if not created:
        old_copy = MyModel.objects.get(id=instance.id)
        diff_fn(old_copy, new_copy)


Since Postgresql only supports READ COMMITTED, implying that reading a row inside a transaction should always return the older value. However, in the code above, old_copy always has updated values meaning that the signal was executed outside transaction (after it was committed.)

Is this the correct behavior? I tried to reason by looking at the code but again not sure.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6ff10ad5-8a5c-0647-f070-e471dae51b77%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to