From c8bcdf7d79c4facb01e9ba1602c578b2e8149593 Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 15 May 2006 18:02:07 +0000 Subject: [PATCH] remove unused threader class git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3182 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/threader.py | 75 ------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/linkcheck/threader.py b/linkcheck/threader.py index e64f6d9c..e556e9cc 100644 --- a/linkcheck/threader.py +++ b/linkcheck/threader.py @@ -71,78 +71,3 @@ def set_thread_priority (prio): res = None return res - -class Threader (object): - """ - A thread generating class. Note that since Python has no ability to - stop threads from outside, one has to make sure threads poll - regularly for outside variables to stop them. Or one makes sure - threads surely will terminate in finite time. - """ - - def __init__ (self, num=5): - """ - Store maximum number of threads to generate, and initialize - an empty thread list. - """ - # this allows negative numbers - self.threads_max = max(num, 0) - # list of active threads to watch - self.threads = [] - - def _acquire (self): - """ - Wait until we are allowed to start a new thread. - """ - while self.active_threads() >= self.threads_max: - self._reduce_threads() - time.sleep(0.1) - - def _reduce_threads (self): - """ - Remove inactive threads. - """ - self.threads = [ t for t in self.threads if t.isAlive() ] - - def active_threads (self): - """ - Return number of active threads. - """ - return len(self.threads) - - def finished (self): - """ - Return True if no active threads are left. - """ - if self.threads_max > 0: - self._reduce_threads() - return self.active_threads() == 0 - - def finish (self): - """ - Remove inactive threads. - """ - self._reduce_threads() - - def start_thread (self, func, args, name=None): - """ - Generate a new thread. - """ - if self.threads_max < 1: - # threading is disabled - func(*args) - else: - self._acquire() - # thread names must be ASCII to avoid conversion problems - assert isinstance(name, str) or name is None, \ - "Invalid name %r" % name - t = threading.Thread(None, func, name, args) - t.start() - self.threads.append(t) - - def __str__ (self): - """ - String representation of threader state. - """ - return "Threader with %d threads (max %d)" % \ - (self.active_threads(), self.threads_max)