Alexei Mozhaev added the comment:
We have a similar bug with Queue.get().
Queue.get(False) raises an exception Queue.Empty in the case when the queue is
actually not empty!
An example of the code is attached and is listed below just in case:
----------------------
import multiprocessing
import Queue
class TestWorker(multiprocessing.Process):
def __init__(self, inQueue):
multiprocessing.Process.__init__(self)
self.inQueue = inQueue
def run(self):
while True:
try:
task = self.inQueue.get(False)
except Queue.Empty:
# I suppose that Queue.Empty exception is about empty queue
# and self.inQueue.empty() must be true in this case
# try to check it using assert
assert self.inQueue.empty()
break
def runTest():
queue = multiprocessing.Queue()
for _ in xrange(10**5):
queue.put(1)
workers = [TestWorker(queue) for _ in xrange(4)]
map(lambda w: w.start(), workers)
map(lambda w: w.join(), workers)
if __name__ == "__main__":
runTest()
----------------------
----------
nosy: +Alexei.Mozhaev
versions: -Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file35000/py_mult_queue_bug.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20147>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com