mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-21 16:30:28 +00:00
add per-host wait times
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3224 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
263a38fbd2
commit
2aed0f3bc5
1 changed files with 10 additions and 1 deletions
11
linkcheck/cache/connection.py
vendored
11
linkcheck/cache/connection.py
vendored
|
|
@ -51,8 +51,17 @@ class ConnectionPool (object):
|
|||
self.connections = {}
|
||||
# {host -> due time}
|
||||
self.times = {}
|
||||
# {host -> wait}
|
||||
self.host_waits = {}
|
||||
self.wait = wait
|
||||
|
||||
@synchronized(_lock)
|
||||
def host_wait (self, host, wait):
|
||||
"""
|
||||
Set a host specific time to wait between requests.
|
||||
"""
|
||||
self.host_waits[host] = wait
|
||||
|
||||
@synchronized(_lock)
|
||||
def add (self, key, conn, timeout):
|
||||
"""
|
||||
|
|
@ -80,7 +89,7 @@ class ConnectionPool (object):
|
|||
"waiting for %.01f seconds on connection to %s", wait, host)
|
||||
time.sleep(wait)
|
||||
t = time.time()
|
||||
self.times[host] = t + self.wait
|
||||
self.times[host] = t + self.host_waits.get(host, self.wait)
|
||||
if key not in self.connections:
|
||||
# not found
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue