This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Alexei.Mozhaev
Recipients Alexei.Mozhaev, torsten
Date 2014-04-22.13:57:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398175032.91.0.639471099228.issue20147@psf.upfronthosting.co.za>
In-reply-to
Content
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()
----------------------
History
Date User Action Args
2014-04-22 13:57:12Alexei.Mozhaevsetrecipients: + Alexei.Mozhaev, torsten
2014-04-22 13:57:12Alexei.Mozhaevsetmessageid: <1398175032.91.0.639471099228.issue20147@psf.upfronthosting.co.za>
2014-04-22 13:57:12Alexei.Mozhaevlinkissue20147 messages
2014-04-22 13:57:12Alexei.Mozhaevcreate