mongodb+pool多进程,在启动时会有如下提示:

/home/kk/python3.6_kk/lib/python3.6/site-packages/pymongo/topology.py:145: UserWarning: 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#pymongo-fork-safe>
"MongoClient opened before fork. Create MongoClient "
/home/kk/python3.6_kk/lib/python3.6/site-packages/pymongo/topology.py:145: UserWarning: 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#pymongo-fork-safe>
"MongoClient opened before fork. Create MongoClient "
/home/kk/python3.6_kk/lib/python3.6/site-packages/pymongo/topology.py:145: UserWarning: 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#pymongo-fork-safe>
"MongoClient opened before fork. Create MongoClient "
/home/kk/python3.6_kk/lib/python3.6/site-packages/pymongo/topology.py:145: UserWarning: 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#pymongo-fork-safe>
"MongoClient opened before fork. Create MongoClient "

 

"MongoClient opened before fork. Create MongoClient "

 

只需要在数据库连接时  加上,connect=False

client=pymongo.MongoClient('localhost',27017,connect=False)

就可以了。

 

 

相关文章:

  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2022-02-23
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
猜你喜欢
  • 2021-10-15
  • 2021-09-28
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
  • 2022-01-21
  • 2021-12-11
相关资源
相似解决方案