mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-20 14:20:59 +00:00
active threads function
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1145 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
26aecf74ec
commit
20b8f0dbc5
1 changed files with 7 additions and 5 deletions
|
|
@ -32,10 +32,8 @@ class Threader (object):
|
|||
|
||||
def _acquire (self):
|
||||
"Wait until we are allowed to start a new thread"
|
||||
while True:
|
||||
while self.active_threads() >= self.threads_max:
|
||||
self._reduce_threads()
|
||||
if len(self.threads) < self.threads_max:
|
||||
break
|
||||
|
||||
|
||||
def _reduce_threads (self):
|
||||
|
|
@ -44,10 +42,14 @@ class Threader (object):
|
|||
self.threads.remove(t)
|
||||
|
||||
|
||||
def active_threads (self):
|
||||
return len(self.threads)
|
||||
|
||||
|
||||
def finished (self):
|
||||
if self.threads_max > 0:
|
||||
self._reduce_threads()
|
||||
return len(self.threads) == 0
|
||||
return self.active_threads() == 0
|
||||
|
||||
|
||||
def finish (self):
|
||||
|
|
@ -68,4 +70,4 @@ class Threader (object):
|
|||
|
||||
def __str__ (self):
|
||||
return "Threader with %d threads (max %d)" % \
|
||||
(len(self.threads), self.threads_max)
|
||||
(self.active_threads(), self.threads_max)
|
||||
|
|
|
|||
Loading…
Reference in a new issue