python - Putting a multiprocessing.Queue in a multiprocessing.Queue explodes -


the following code throws exception , prints 123 in both python 2.7 , 3.3.

from multiprocessing import queue  class pool(object):     def __init__(self):         self.q = queue()  p = pool() p.q.put(p) print(123) 

it's sort of race condition can seen here:

yuv@yuvpad2:~/$ python3.3 t.py 123 traceback (most recent call last):   file "/home/yuv/downloads/python-3.3.0/lib/multiprocessing/queues.py", line 249, in _feed yuv@yuvpad2:~/$  

the full error runtimeerror: queue objects should shared between processes through inheritance , traceback doesn't @ explain how/where happens. source of problem object in queue can't reference queue. real use case worker object , pool object, worker reports finished working pool's queue. wanted worker send worker queue.

the reason i'm not using queue.queue,although multithreading work case, because in python 2.7 there's bug makes queue.get() ignore ctrl-c annoying.

is there way pattern cleanly?

the real problem code on codepad

i guess there couple of ways this, without knowing wan't it's hard recommend one.

i guess easiest 1 using 2 different queues purpose. 1 incoming workers , 1 fore finished workers.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -