一个简单的例子重现这个报错:
from multiprocessing.dummy import Pool as ThreadPool
import threading
def work():
l = [1,2,3]
pool = ThreadPool(3)
pool.map(work2,l)
pool.close()
pool.join()
if __name__ == '__main__':
t = threading.Thread(target=work)
t.start()
错误信息:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/eggeek/palendar/geodata/operation/praser.py", line 7, in work
pool = ThreadPool(3)
File "/usr/lib/python2.7/multiprocessing/dummy/__init__.py", line 150, in Pool
return ThreadPool(processes, initializer, initargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 685, in __init__
Pool.__init__(self, processes, initializer, initargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 136, in __init__
self._repopulate_pool()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 199, in _repopulate_pool
w.start()
File "/usr/lib/python2.7/multiprocessing/dummy/__init__.py", line 73, in start
self._parent._children[self] = None
AttributeError: 'Thread' object has no attribute '_children'