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?
Hi guys,
We just run into an issue when archiving data from one collection into another using
switch_collectionin multi threaded environment (sample code we used below):The scenario is a following:
1st thread runs
archive, executesself.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 preferablyswitch_db) method thread safe.What do you think?