mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-29 20:20:30 +00:00
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:
parent
3be005186a
commit
bb3b972d8f
1 changed files with 6 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue