Terminate a thread that doesn't check for events
Liu Shuai
lshuai at kaneva.com
Tue Aug 2 09:51:31 EDT 2005
Can someone please comment on this?
________________________________
From: python-list-bounces+sliu=kaneva.com at python.org
[mailto:python-list-bounces+sliu=kaneva.com at python.org] On Behalf Of Liu
Shuai
Sent: Monday, August 01, 2005 4:29 PM
To: python-list at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050802/d0cdb5c6/attachment.html>
More information about the Python-list
mailing list