From 4c8dcb012b816eef9648ec048433b2b7613e09ab Mon Sep 17 00:00:00 2001 From: calvin Date: Wed, 24 May 2006 22:29:22 +0000 Subject: [PATCH] added a stoppable thread object git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3305 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/threader.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/linkcheck/threader.py b/linkcheck/threader.py index 940f04ea..1f964069 100644 --- a/linkcheck/threader.py +++ b/linkcheck/threader.py @@ -19,6 +19,7 @@ Support for managing threads. """ import os +import threading try: import win32process _has_win32process = True @@ -65,3 +66,15 @@ def set_thread_priority (prio): res = None return res + +class StoppableThread (threading.Thread): + + def __init__ (self): + super(StoppableThread, self).__init__() + self._stop = threading.Event() + + def stop (self): + self._stop.set() + + def stopped (self): + return self._stop.isSet()