2014-07-09 30 views
5

用下面的代碼使得:'集合' 的對象不是在pymongo可調用錯誤與處理池

'Collection' object is not callable. If you meant to call the '__getnewargs__' method on a 'Collection' object it is failing because no such method exists. 

的代碼: 從多處理進口普爾 分貝= MongoClient(IP,端口)

def f(cursor, arg): 
    for doc in cursor: 
     ... 

p = Pool(4) 
for arg in args: 
    cursor = db[dbName][collName].find() 
    p.apply_async(f,[cursor, arg]) 

db.close() 

找不出什麼問題以及如何調試代碼。

完全回溯:

Exception in thread Thread-2: 
Traceback (most recent call last): 
    File "C:\Python27\lib\threading.py", line 808, in __bootstrap_inner 
    self.run() 
    File "C:\Python27\lib\threading.py", line 761, in run 
    self.__target(*self.__args, **self.__kwargs) 
    File "C:\Python27\lib\multiprocessing\pool.py", line 342, in _handle_tasks 
    put(task) 
    File "C:\Python27\lib\site-packages\pymongo\collection.py", line 1489, in __call__ 
    self.__name.split(".")[-1]) 
TypeError: 'Collection' object is not callable. If you meant to call the '__getnewargs__' method on a 'Collection' object it is failing because no such method exists. 
+1

在克隆光標線程之前顯式拉文件錯誤發生在哪一行? –

+0

已更新爲完整回溯 – user1264304

+0

是從最高級'multiprocessing'軟件包,還是從其他模塊(如'multiprocessing.dummy'或pymongo中的某個模塊)導入'Pool'? – Blckknght

回答

相關問題