I have several view functions that process data from remote sources. In many cases this processing can take over a second to complete. Will simultaneous access to these view functions potentially scramble my data?
In addition, I will have a continually-running background thread that will be populating my database. This background thread will be calling some of the same library functions that my view functions will be calling. Is this a potential thread-safety issue?
If yes, what are the best practices? I’m assuming just using python’s locking mechanism will work, but are there better approaches?
Thanks!
-Travis
For long running processes, use Celery.
For a long view, you can create a model instance, and start a celery task which populates it. A view can show the status of this instance, with self refreshing html until the results are there.