出于某种原因,ReplicaSet的监视器在安排刷新时显得已经死亡。
我在调用find_one()时跟踪了Traceback:
File "pymongo/collection.py", line 604, in find_one
for result in self.find(spec_or_id, *args, **kwargs).limit(-1):
File "pymongo/cursor.py", line 904, in next
if len(self.__data) or self._refresh():
File "pymongo/cursor.py", line 848, in _refresh
self.__uuid_subtype))
File "pymongo/cursor.py", line 805, in __send_message
client.disconnect()
File "pymongo/mongo_replica_set_client.py", line 1255, in disconnect
self.__schedule_refresh()
File "pymongo/mongo_replica_set_client.py", line 1067, in __schedule_refresh
self.__monitor.schedule_refresh()
File "pymongo/mongo_replica_set_client.py", line 295, in schedule_refresh
"Monitor thread is dead: Perhaps started before a fork?")
我研究了一些代码,发现Monitor.monitor()包含:
# RSC has been collected or there
# was an unexpected error.
except:
break
这意味着无论发生什么不好,我都不会发现它是什么。
那么,如果我捕获InvalidOperation(" Monitor线程已经死了:也许在fork之前启动了?")
我该怎么办?是否有一些很好的方法可以重新启动Monitor实例?
(我使用flask-pymongo和pymongo.version 2.6.2)