Terminate a thread that doesn't check for events

Liu Shuai lshuai at kaneva.com
Mon Aug 1 22:29:22 CEST 2005

Hi all,


I am aware that similar and probably same questions have been posted
many times, but I was unable to find a solution after reading a dozen
threads in the archive. So here it goes again.


I have a thread that does some heavy task (hash calculation, for
instance). I need a mechanism that works *across platforms* to stop that
calculation if user decides to exit. How can I do that? 

I can not do the standard "periodical checking" way since there is only
one function/step call in my thread.


Here is a snippet of my thread classes to help illustrate the problem:


class Dispatcher():

    def __init__(self):        

            self.__worker = Worker() 


    def start(self):



    def stop():

            #how do i stop the worker?


class Worker(threading.Thread):

    def __init__(self):


    def run(self):




Thank you in advance for any suggestions/pointers.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050801/acfb1d60/attachment.html>

More information about the Python-list mailing list