how can a child thread notify a parent thread its status?

Piet van Oostrum piet at
Sat Jul 25 07:14:08 EDT 2009

>>>>> davidj411 <davidj411 at> (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:

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.


(Thanks to Dennis Lee Bieber)

Instead of None you can also create a special sentinel object and use that.
Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list