diff --git a/linkcheck/Threader.py b/linkcheck/Threader.py index 8a4d8c2d..88ba8b9b 100644 --- a/linkcheck/Threader.py +++ b/linkcheck/Threader.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +import time try: import threading as _threading except ImportError: @@ -34,12 +35,11 @@ class Threader (object): "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): - for t in self.threads: - if not t.isAlive(): - self.threads.remove(t) + self.threads = [ t for t in self.threads if t.isAlive() ] def active_threads (self): diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py index d723932b..64beb89b 100644 --- a/linkcheck/__init__.py +++ b/linkcheck/__init__.py @@ -16,9 +16,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + class LinkCheckerError (Exception): pass + import time, re, i18n def getLinkPat (arg, strict=False): """get a link pattern matcher for intern/extern links""" @@ -47,6 +49,7 @@ import UrlData from debug import * from linkcheck.log import strduration + # main check function def checkUrls (config): """ checkUrls gets a complete configuration object as parameter where all @@ -61,9 +64,11 @@ def checkUrls (config): try: start_time = time.time() status_time = start_time - while not config.finished(): + while True: if config.hasMoreUrls(): config.checkUrl(config.getUrl()) + elif config.finished(): + break else: # active connections are downloading/parsing, so # wait a little