how does a queue stop the thread?

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


On Wed, Apr 21, 2010 at 1:50 PM, Kushal Kumaran
<kushal.kumaran+python at gmail.com> wrote:
> 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>
>

And I should have read your mail better.  Take a look at the
documentation of the task_done method:
http://docs.python.org/library/queue.html

-- 
regards,
kushal



More information about the Python-list mailing list