def open(self):
"""Start monitoring, or restart after a fork.
No effect if called multiple times.
.. warning:: To avoid a deadlock during Python's getaddrinfo call,
will generate a warning if open() is called from a different
process than the one that initialized the Topology. To prevent this
from happening, MongoClient must be created after any forking OR
MongoClient must be started with connect=False.
"""
with self._lock:
if self._pid is None:
self._pid = os.getpid()
else:
if os.getpid() != self._pid:
warnings.warn(
"MongoClient opened before fork. Create MongoClient "
"with connect=False, or create client after forking. "
"See PyMongo's documentation for details: http://api."
"mongodb.org/python/current/faq.html#using-pymongo-"
"with-multiprocessing>")
self._ensure_opened()
评论列表
文章目录