>>>>> davidj411 <[email protected]> (d) wrote:
>d> could i see an example of this maybe?
queue is a shared Queue instance.
The parent puts the work in the queue with queue.put(work_object).
After all work has been put in the queue it puts a sentinel
queue.put(None)
Each child thread (consumer) has a loop getting things out of the queue:
while True:
work = queue.get()
if work is None: break
#do real stuff using work
queue.put(None) #put back the sentinel for other worker threads.
#finish
(Thanks to Dennis Lee Bieber)
Instead of None you can also create a special sentinel object and use that.
--
Piet van Oostrum <[email protected]>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [email protected]
--
http://mail.python.org/mailman/listinfo/python-list