mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-15 20:01:03 +00:00
add Timeout exception, and return in_progress URLs on status instead of unfinished
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3187 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
b1e7ca58a2
commit
b3b45d7f06
1 changed files with 9 additions and 3 deletions
12
linkcheck/cache/urlqueue.py
vendored
12
linkcheck/cache/urlqueue.py
vendored
|
|
@ -24,6 +24,11 @@ import linkcheck
|
|||
import linkcheck.log
|
||||
|
||||
|
||||
class Timeout (Exception):
|
||||
"""Raised by join()"""
|
||||
pass
|
||||
|
||||
|
||||
class UrlQueue (Queue.Queue):
|
||||
"""
|
||||
A queue supporting several consumer tasks. The task_done() idea is
|
||||
|
|
@ -167,7 +172,7 @@ class UrlQueue (Queue.Queue):
|
|||
while self.unfinished_tasks:
|
||||
remaining = endtime - time.time()
|
||||
if remaining <= 0.0:
|
||||
return
|
||||
raise Timeout()
|
||||
self.all_tasks_done.wait(remaining)
|
||||
finally:
|
||||
self.all_tasks_done.release()
|
||||
|
|
@ -191,11 +196,12 @@ class UrlQueue (Queue.Queue):
|
|||
|
||||
def status (self):
|
||||
"""
|
||||
Get tuple (finished tasks, unfinished tasks, queue size).
|
||||
Get tuple (finished tasks, in progress, queue size).
|
||||
"""
|
||||
self.mutex.acquire()
|
||||
try:
|
||||
return (self.finished_tasks, self.unfinished_tasks, len(self.queue))
|
||||
return (self.finished_tasks,
|
||||
len(self.in_progress), len(self.queue))
|
||||
finally:
|
||||
self.mutex.release()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue