参考: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()