DEV Community

Discussion on: Django: Fixing race condition when queuing with on_commit hook

Collapse
 
rhymes profile image
rhymes

What if instead of hooking to the transaction callbacks you send the message on the queue with a signal on post_save ?

This way if there is an error the message won't be saved or queued, if the message is saved in the database you can be sure that it is sent to the queue after being saved

Collapse
 
k4ml profile image
Kamal Mustafa

Hmm, that make sense. I'll look back into our code and see if that feasible. Thanks for the suggestion !

Ok, on a second thought, I try to avoid using signal as it make code hard to follow.

Collapse
 
rhymes profile image
rhymes

He has a point, thanks for telling me! I'll consider it :-)