On Wed, Apr 23, 2008 at 9:46 AM, bob gailer <[EMAIL PROTECTED]> wrote:
> 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. 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. 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: - get() and put() are thread safe - get() blocks if the queue is empty - no need for a polling loop - put() blocks if the queue is full Additionally if the consumers call Queue.task_done() for each consumed item, Queue.join() will block until all tasks are complete, then continue. Kent
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor