Sử dụng mã dưới đây gây ra:đối tượng 'Bộ sưu tập' không phải là lỗi callable trong pymongo với quá trình Pool
'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.
Mã: từ đa xử nhập khẩu Pool db = MongoClient (ip, port)
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()
Không thể tìm ra vấn đề là gì và cách gỡ lỗi mã.
Full Traceback:
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.
Tại lỗi nào xảy ra? –
được cập nhật với traceback đầy đủ – user1264304
'Pool' được nhập từ gói' multiprocessing' cấp cao nhất hay từ một số mô-đun khác (như 'multiprocessing.dummy' hay gì đó trong pymongo)? – Blckknght