how does a queue stop the thread?

Kushal Kumaran kushal.kumaran+python at gmail.com
Wed Apr 21 04:20:15 EDT 2010


On Wed, Apr 21, 2010 at 1:38 PM, kaiix <kvn.hou at gmail.com> wrote:
> A simple thread pool example. My question is, since *MyThread.run*
> will loop endless, how does the thread know the time to quit? how does
> the *queue* notify the thread? is there any shared variables, like a
> *lock*?
>
> When I set daemon false, it stays in the loop, not quit any more.
> what's the role does the daemon state plays?
>

Take a look at the documentation for the threading module here:
http://docs.python.org/release/2.6/library/threading.html, and the
discussion on daemon vs non-daemon threads here:
http://blog.doughellmann.com/2008/01/pymotw-threading_13.html

Basically, as long as at least one non-daemon thread is still running,
your program will not exit.

> <snip code>

-- 
regards,
kushal



More information about the Python-list mailing list