Django's post_save doesn't always

I am developer/code-reviewer/debugger/bug-fixer/architect/teacher/builder from dubai, uae
Search for a command to run...

I am developer/code-reviewer/debugger/bug-fixer/architect/teacher/builder from dubai, uae
No comments yet. Be the first to comment.
You Should Tell Yourself

A URL shortener is a proxy service that provides a mapping between the short and full representation of a URL. The short URL has the advantage of being small. The service can also provide useful analy

Listening to the Mel Robbins's podcast on regrets was a 'ear'-opener. One can have reqrets of action or inaction. 4 types of reqrets foundation - should've done the work boldness - should've taken t

We need to create a unique ID generator for our high-traffic web application, generating about 10K IDs/second. The IDs can't simply be monotonically increasing integers, which are good for data access
doing + telling

Django’s post_save methods allow execution of custom code on an insert or update of a record after the save method is called.
The serialized object propagates through the signal handlers as the instance parameter which is eventually committed to the database only if no exceptions occur in any of the methods that listen to the signal.
Handlers:
can be multiple which are synchronously chained
will executed non-deterministically as per the signal’s receiver registration
will execute prior to a transaction commit
will short-circuit execution on failure
Data inconsistencies are caused where proceeding methods in the post_save chain aren’t called after the one that throws an unhandled exception. The database record is not updated.
Additionally, the instance parameter has the most up-to date state which on an update, will revise the stale content that resides in the DB.
To avoid issues:
Use transaction on_commit to guarantee the data consistency
Use the instance argument over re-reading it from the DB in handlers
References