stop a thread safetely

Jp Calderone exarkun at divmod.com
Fri May 13 12:32:27 EDT 2005


On Fri, 13 May 2005 16:47:34 +0200, Zunbeltz Izaola <zunbeltz at gmail.com> wrote:
>On Fri, 13 May 2005 09:10:13 -0400, Peter Hansen wrote:
>
>>
>> How did you intend to stop the thread in a manner which might be unsafe?
>> (Hint, unless you're doing something unusual, you can't.)
>>
>
>I have a threaded object (Mythread). It checks if want_thread
>variable is True to return. The problem is that this object
>execute a function that is a tcp comunication
>

  You cannot exit a thread except by exiting the entire process or by having the function it is running terminate (either by returning or raising an exception).

  Instead of using threads for network communication, you may want to look into these:

    http://www.twistedmatrix.com/

    http://python.org/doc/lib/module-asyncore.html

    http://www.nightmare.com/medusa/

  Hope this helps,

  Jp



More information about the Python-list mailing list