-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Hi guys,
We just run into an issue when archiving data from one collection into another using switch_collection
in multi threaded environment (sample code we used below):
def archive(self):
self.switch_collection(Item._meta['archive_collection'])
self.save()
self.switch_collection(Item._meta['collection'])
self.delete()
The scenario is a following:
1st thread runs archive
, executes self.switch_collection(Item._meta['archive_collection'])
2nd thread wants to query different document and doesn't find it, because 1st thread has switched collection.
It would be a good idea to make switch_collection
(and preferably switch_db
) method thread safe.
What do you think?
julianwachholz, iburakov, shahjahan-nykaa, goal, pawciobiel and 1 more