Hi list,

I recently found a bug in my company's code because of a strange behavior
using multiprocessing.Queue. The following code snippet:

from multiprocessing import Queue

queue = Queue()
queue.put('x')
print queue.get_nowait()

Fails with:

...
  File
"E:\Shared\dist-0902\i686.win32\processing-0.52\lib\site-packages\processing\queue.py",
line 153, in getNoWait
    return self.get(False)
  File
"E:\Shared\dist-0902\i686.win32\processing-0.52\lib\site-packages\processing\queue.py",
line 129, in get
    raise Empty
Queue.Empty

Strangely, changing this to:

queue = Queue()
queue.put('x')
time.sleep(0.1) # <<<
print queue.get_nowait()

Works as expected. Using the original snippet changing the import to
threading's Queue also works.

It seems like there's a bug in multiprocessing's Queue implementation.
Opinions?

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to