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!