how can a child thread notify a parent thread its status?
Piet van Oostrum
piet at cs.uu.nl
Sat Jul 25 07:14:08 EDT 2009
>>>>> davidj411 <davidj411 at gmail.com> (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
Each child thread (consumer) has a loop getting things out of the queue:
work = queue.get()
if work is None: break
#do real stuff using work
queue.put(None) #put back the sentinel for other worker threads.
(Thanks to Dennis Lee Bieber)
Instead of None you can also create a special sentinel object and use that.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list