mongodb - python運行多執行緒庫pathos時,pymongo遞歸深度溢出
淡淡烟草味
淡淡烟草味 2017-05-02 09:19:12
0
0
692

版本: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))
    

出現了很多行相同的錯誤提示:

淡淡烟草味
淡淡烟草味

全部回覆(0)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!