Open
Description
I have multiple green threads that try to with switch_db(SomeDocument, alias):...
on the same document in order to query multiple aliases.
Once in a while I get an exception:
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/queryset.py", line 104, in count
return super(QuerySet, self).count(with_limit_and_skip)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 347, in count
return self._cursor.count(with_limit_and_skip=with_limit_and_skip)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 1481, in _cursor
self._cursor_obj = self._collection.find(self._query,
AttributeError: 'NoneType' object has no attribute 'find'
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/queryset.py", line 104, in count
return super(QuerySet, self).count(with_limit_and_skip)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 347, in count
return self._cursor.count(with_limit_and_skip=with_limit_and_skip)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 1481, in _cursor
self._cursor_obj = self._collection.find(self._query,
AttributeError: 'NoneType' object has no attribute 'find'
It happens possibly due to self.cls._collection = None
in switch_db.enter function.
I'm using mongoengine 0.10.6