From 2aed0f3bc51cbdc2d199b2c4f10ee8a461c4931e Mon Sep 17 00:00:00 2001 From: calvin Date: Tue, 16 May 2006 23:03:44 +0000 Subject: [PATCH] add per-host wait times git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3224 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/cache/connection.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/linkcheck/cache/connection.py b/linkcheck/cache/connection.py index 83c4ef0b..e29d0f8b 100644 --- a/linkcheck/cache/connection.py +++ b/linkcheck/cache/connection.py @@ -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