Commits

benoitc  committed 64dc3f6

pass pool params to the pool and make sure we release connection

  • Participants
  • Parent commits aece14e

Comments (0)

Files changed (1)

File restkit/httpc.py

         if conn_key in self.connections:
             pool = self.connections[conn_key]
         else:
-            pool = self.connections[conn_key] = self.pool_class(uri, self.use_proxy)
+            pool = self.connections[conn_key] = self.pool_class(uri, 
+                use_proxy=self.use_proxy, min_size=self.min_size,
+                max_size=self.max_size)
         connection = pool.get()
         return connection
         
         if conn_key in self.connections:
             pool = self.connections[conn_key]
         else:
-            pool = self.connections[conn_key] =self.pool_class(uri, self.use_proxy)
+            pool = self.connections[conn_key] =self.pool_class(uri,  
+                use_proxy=self.use_proxy, min_size=self.min_size,
+                max_size=self.max_size)
         pool.put(connection)
 
             
                     
             except socket.gaierror:
                 connection.close()
+                self._release_connection(uri, connection)
                 raise errors.ResourceNotFound("Unable to find the server at %s" % connection.host, 404)
             except (socket.error, httplib.HTTPException):
                 connection.close()
+                self._release_connection(uri, connection)
                 if i == 0:
                     continue
                 else:
         resp.final_url = self.final_url
         
         if method == "HEAD":
-            connection.close()
+            response.close()
+            self._release_connection(uri, connection)
             return resp, ""
         else:
             return resp, _decompress_content(resp, response, 
                 release_callback()
                 return data
     except Exception, e:
+        release_callback()
         raise errors.ResponseError("Decompression failed %s" % str(e))