From 61fc7ab5027fe08a69e9d5cf86e05484507f239e Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 15 May 2006 18:36:55 +0000 Subject: [PATCH] since join() is not interruptable, put in a little sleep() call git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3191 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/director/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/linkcheck/director/__init__.py b/linkcheck/director/__init__.py index c2f9d68f..7e4acedb 100644 --- a/linkcheck/director/__init__.py +++ b/linkcheck/director/__init__.py @@ -17,6 +17,7 @@ """ Management of checking a queue of links with several threads. """ +import time import linkcheck import linkcheck.log import linkcheck.cache.urlqueue @@ -37,8 +38,14 @@ def check_urls (aggregate): aggregate.logger.start_log_output() if not aggregate.urlqueue.empty(): aggregate.start_threads() - # blocks until all urls are checked - aggregate.urlqueue.join() + # Since urlqueue.join() is not interruptable, add a timeout + # and a one-second slumber. + while True: + try: + aggregate.urlqueue.join(timeout=1) + break + except linkcheck.cache.urlqueue.Timeout: + time.sleep(1) except KeyboardInterrupt: linkcheck.log.warn(linkcheck.LOG_CHECK, "keyboard interrupt; waiting for active threads to finish")