From bb3b972d8f033003ffbff3199d35943a93b05723 Mon Sep 17 00:00:00 2001 From: calvin Date: Sun, 6 Feb 2005 21:20:10 +0000 Subject: [PATCH] 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 --- linkcheck/checker/pool.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linkcheck/checker/pool.py b/linkcheck/checker/pool.py index 59071fd2..5e705d9f 100644 --- a/linkcheck/checker/pool.py +++ b/linkcheck/checker/pool.py @@ -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