Can someone please comment on this?

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Liu Shuai
Sent: Monday, August 01, 2005 4:29 PM
To: python-list@python.org
Subject: Terminate a thread that doesn't check for events

 

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):

        self.__worker.start()       

   

    def stop():

            #how do i stop the worker?

 

class Worker(threading.Thread):

    def __init__(self):

   

    def run(self):

            oneTimeConsumingCall()

 

 

Thank you in advance for any suggestions/pointers.

 

LS

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to