我有一个
AttributeError: '_MainProcess' object has no attribute '_exiting'
来自 Python 应用程序。不幸的是,这段代码必须运行 Python 2.5,因此processing
现在称为multiprocessing
. 我正在做的是从主进程创建一个Process
带有Queue
和put
的队列中的一个项目。查看processing.queue
代码,我可以看到一个馈线线程已启动。然后,该馈线线程将检查currentProcess()._exiting
,但currentProcess()
评估为_MainProcess
不具有所述属性的 a ,如processing.process
模块中所示。如何解决这个问题?它是一个错误processing
吗?如果是,我可以简单地使用猴子补丁currentProcess()._exiting = False
吗?
最小的例子:
#!/usr/bin/python
import processing
import processing.queue
class Worker(processing.Process):
def __init__(self):
processing.Process.__init__(self)
self.queue = processing.queue.Queue()
def run(self):
element = self.queue.get()
print element
if __name__ == '__main__':
w = Worker()
w.start()
# To trigger the problem, any non-pickleable object is to be passed here.
w.queue.put(lambda x: 1)
w.join()