I got an
AttributeError: '_MainProcess' object has no attribute '_exiting'
from a Python application. Unfortunately this code has to run Python 2.5 and therefore the processing
module nowadays known as multiprocessing
. What I was doing is to create a Process
with a Queue
and to put
an item in the queue from the main process. Looking into the processing.queue
code I can see that a feeder thread is started. This feeder thread will then check currentProcess()._exiting
, but currentProcess()
evaluates to a _MainProcess
which does not have said attribute as can be seen in the processing.process
module. How to solve this? Is it a bug in processing
? If yes, can I simply monkeypatch it using currentProcess()._exiting = False
?
Minimal example:
#!/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()