玩蛇网提供最新Python编程技术信息以及Python资源下载!

python threading线程再次开启多线程AttributeError错误应对方案是什么

一个简单的例子重现这个报错:

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'

这是一个python的bug,参考 http://bugs.python.org/issue10015

可以按照里面的方法来绕过去,或者升级到python 2.7.5 或者 3.3.2

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd19791.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月24日 - 20时28分22秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules