mongodb - python运行多线程库pathos时,pymongo递归深度溢出

 Yunir_944 发布于 2022-10-25 00:59

版本:pymongo 3.2.2;python 2.7;mongodb 3.0.12;pathos 0.2a1.dev0
在使用pathos的python多线程/进程库时,遇到了如下错误,注释掉“self.db_userinfo_table = MongoClient('localhost',27017).collection.example”这一行,就可以正常运行,如果不注释数据库初始化这一行,“result = ProcessPool(4).map(r.compute, range(100))”这句就会出错,但数据库还没使用呀,仅仅是初始化,难道pymongo本身有bug,还是pathos有bug?

from pathos.pools import ProcessPool, ThreadPool
import logging
from pymongo import MongoClient

class PMPExample(object):
    def __init__(self):
        self.cache = {}
        self.db_userinfo_table  = MongoClient('localhost',27017).collection.example
    def compute(self, x):
        self.cache[x] = x ** 3
        return self.cache[x]

if __name__ == '__main__':
    logging.basicConfig()
    log = logging.getLogger(__name__)
    log.setLevel(logging.INFO)
    r = PMPExample()
    #result = ThreadPool(4).map(r.compute, range(100))
    result = ProcessPool(4).map(r.compute, range(100))
    log.info("result processpooled caches: {}".format(result))
    

出现了好多行同样的错误提示:

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有