On Wed, Apr 23, 2008 at 9:46 AM, bob gailer <<a href="mailto:bgailer@gmail.com">bgailer@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Evey time someone recommends Queue I think "oh boy this will really help me". Then I go to the Library Reference, read the Queue docs and think "oh boy who can help me understand this". Even the sample code is confusing.</blockquote>
<div><br>Can you say what is confusing about it? Do you have a specific use in mind? Do you understand threading? Queue is used to facilitate communication between threads, so any Queue example includes multiple threads.<br>
<br>In the simplest case, you have producer and consumer threads, and a single shared instance of Queue. Each producer thread adds items to the queue using Queue.put(). Consumer threads remove items with Queue.get(). The benefits:<br>
- get() and put() are thread safe<br>- get() blocks if the queue is empty - no need for a polling loop<br>- put() blocks if the queue is full<br><br>Additionally if the consumers call Queue.task_done() for each consumed item, Queue.join() will block until all tasks are complete, then continue.<br>
<br>Kent<br></div></div><br>