[Tutor] how to stop a thread

shawn bright nephish at gmail.com
Thu Jan 4 16:25:27 CET 2007


i can do that, will use my config file,
thanks much
and thanks for the link.


shawn

On 1/4/07, Kent Johnson <kent37 at tds.net> wrote:
>
> shawn bright wrote:
> > hello there all,
> >
> > i have a python reference book that got me started knowing how to use
> > threads, i can declare one as a class, and start it like this
> >
> > class SomeThread(threading.Thread):
> >
> >
> > run_process = SomeThread()
> > run_process.start()
> >
> > but how do i kill it ? This part is not in my book. Basically the thread
> > works, and runs in a while loop. Is there a way to destroy the instance
> > of it after creation ?
>
> A thread dies when it's run() method exits, so you have to contrive a
> way to make run() exit. The usual way is to set a flag that the thread
> checks. Here is an example using a threading.Event as a flag:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65448
>
> Kent
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070104/3b688f06/attachment.html 


More information about the Tutor mailing list