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:
calvin 2006-05-16 23:03:44 +00:00
parent 263a38fbd2
commit 2aed0f3bc5

View file

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