Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Queue module get stuck

In Python2.7, when using Queue module:

q = Queue.PriorityQueue(maxsize=3)
q.put((1,'foo'))
q.put((2,'bar'))
q.put((3,'baz'))
q.put((4,'boo'))   # on purpose

Then the script get stuck. I also tried in Ipython, it gets stuck when I put the 4th item. Why is this happening? And how do I correctly use PriorityQueue to create a given size priority queue.

like image 992
wilbeibi Avatar asked Oct 28 '25 10:10

wilbeibi


1 Answers

According to Queue module documentation:

Queue.put(item[, block[, timeout]])

Put item into the queue. If optional args block is true and timeout is None (the default), block if necessary until a free slot is available. If timeout is a positive number, it blocks at most timeout seconds and raises the Full exception if no free slot was available within that time. Otherwise (block is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (timeout is ignored in that case).

like image 162
falsetru Avatar answered Oct 30 '25 00:10

falsetru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!