[Answer]-Threadsafe way to access database using django

1👍

The thread-safety issue with the DB has nothing to do with the connection; it’s when two threads try to alter the same piece of data simulataneously, or even one trying to write while the other tries to read. In order to prevent this, you simply need to lock the table when one of your threads needs to do something with it. A quick and easy way with Django 1.4+ is to use select_for_update, which will lock the table until you do an update operation.

Leave a comment