always add connections, and close timed out ones

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2277 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-02-06 21:20:10 +00:00
parent 3be005186a
commit bb3b972d8f

View file

@ -45,10 +45,7 @@ class ConnectionPool (object):
Add connection to the pool with given identifier key and timeout
in seconds.
"""
cached = key in self.connections
if not cached:
self.connections[key] = [conn, 'available', time.time() + timeout]
return cached
self.connections[key] = [conn, 'available', time.time() + timeout]
def get_connection (self, key):
"""
@ -64,6 +61,11 @@ class ConnectionPool (object):
t = time.time()
if t > conn_data[2]:
# timed out
try:
conn_data[1].close()
except:
# ignore close errors
pass
del self.connections[key]
return None
# wait at most 300*0.1=30 seconds for connection to become available