参考:http://api.mongodb.com/python/current/faq.html#using-pymongo-with-multiprocessing

 

如果使用了多进程,则必须在子进程中创建mongo连接。不能创建一个mongo连接传给多个进程!!

 

# Each process creates its own instance of MongoClient.
def func():
    db = pymongo.MongoClient().mydb
    # Do something with db.

proc = multiprocessing.Process(target=func)
proc.start()

 

相关文章:

  • 2021-11-08
  • 2021-06-27
  • 2021-07-03
  • 2021-05-20
  • 2021-07-07
  • 2021-08-26
  • 2021-10-10
  • 2021-08-31
猜你喜欢
  • 2021-04-21
  • 2021-08-02
  • 2021-12-23
  • 2021-12-10
  • 2022-02-10
  • 2021-09-27
相关资源
相似解决方案