Message217004
| 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:12 | Alexei.Mozhaev | set | recipients:
+ Alexei.Mozhaev, torsten |
| 2014年04月22日 13:57:12 | Alexei.Mozhaev | set | messageid: <1398175032.91.0.639471099228.issue20147@psf.upfronthosting.co.za> |
| 2014年04月22日 13:57:12 | Alexei.Mozhaev | link | issue20147 messages |
| 2014年04月22日 13:57:12 | Alexei.Mozhaev | create |
|