mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-17 12:51:01 +00:00
ignore keyboard interrupts during shutdown
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3458 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
2dd310f3d2
commit
ae245287b6
2 changed files with 39 additions and 16 deletions
|
|
@ -25,6 +25,10 @@
|
|||
Type: feature
|
||||
Changed: linkcheck/httplib2.py
|
||||
|
||||
* Ignore keyboard interrupts during shutdown.
|
||||
Type: bugfix
|
||||
Changed: linkcheck/director/__init__.py
|
||||
|
||||
4.3 "Brick" (released 17.8.2006)
|
||||
|
||||
* Use RawConfigParser for config parsing, getting rid of the unused
|
||||
|
|
|
|||
|
|
@ -38,28 +38,47 @@ def check_urls (aggregate):
|
|||
aggregate.logger.start_log_output()
|
||||
if not aggregate.urlqueue.empty():
|
||||
aggregate.start_threads()
|
||||
# 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)
|
||||
aggregate.remove_stopped_threads()
|
||||
if not aggregate.threads:
|
||||
break
|
||||
check_url(aggregate)
|
||||
aggregate.finish()
|
||||
aggregate.logger.end_log_output()
|
||||
except KeyboardInterrupt:
|
||||
linkcheck.log.warn(linkcheck.LOG_CHECK,
|
||||
_("keyboard interrupt; waiting for active threads to finish"))
|
||||
aggregate.abort()
|
||||
_("keyboard interrupt; waiting for active threads to finish"))
|
||||
abort(aggregate)
|
||||
except:
|
||||
console.internal_error()
|
||||
aggregate.abort()
|
||||
aggregate.finish()
|
||||
aggregate.logger.end_log_output()
|
||||
abort(aggregate)
|
||||
|
||||
|
||||
def check_url (aggregate):
|
||||
"""
|
||||
Helper function waiting for URL queue.
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
aggregate.urlqueue.join(timeout=1)
|
||||
break
|
||||
except linkcheck.cache.urlqueue.Timeout:
|
||||
# Since urlqueue.join() is not interruptable, add a timeout
|
||||
# and a one-second slumber.
|
||||
time.sleep(1)
|
||||
aggregate.remove_stopped_threads()
|
||||
if not aggregate.threads:
|
||||
break
|
||||
|
||||
def abort (aggregate):
|
||||
"""
|
||||
Helper function to ensure a clean shutdown.
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
aggregate.abort()
|
||||
aggregate.finish()
|
||||
aggregate.logger.end_log_output()
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
linkcheck.log.warn(linkcheck.LOG_CHECK, _("shutdown in progress"))
|
||||
|
||||
def get_aggregate (config):
|
||||
"""
|
||||
Get an aggregator instance with given configuration.
|
||||
|
|
|
|||
Loading…
Reference in a new issue