[Tutor] how to stop a thread
nephish at gmail.com
Thu Jan 4 16:25:27 CET 2007
i can do that, will use my config file,
and thanks for the link.
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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor