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
This commit is contained in:
calvin 2006-05-15 18:36:55 +00:00
parent ec2756021f
commit 61fc7ab502

View file

@ -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")