[Tutor] threading
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Aug 16 07:56:31 CEST 2006
> It kinda depends what your thread is doing, and what technique you are
> using to keep it alive, but one possibility is to do something like:
>
> class Worker(threading.Thread):
> def run(self):
> self.running = True
> while(self.running):
> # do stuff
>
> def stop(self):
> self.running = False
>
> In this case, the you call .stop() on your Worker object, and the thread
> will exit when it next gets to the top of the while loop.
Hi Jeff,
Another variation of this is in here:
http://mail.python.org/pipermail/tutor/2006-January/044557.html
Some of the method names in that old message are badly named, but I hope
its ideas are clear.
More information about the Tutor
mailing list