Commit 79568a61 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Merge _createNodeConnection in getConnForNode.

So that search and add in connection_dict is made in the same method.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2577 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9756d1f3
......@@ -112,18 +112,6 @@ class ConnectionPool(object):
finally:
conn.unlock()
@profiler_decorator
def _createNodeConnection(self, node):
"""Create a connection to a given storage node."""
if len(self.connection_dict) > self.max_pool_size:
# must drop some unused connections
self._dropConnections()
conn = self._initNodeConnection(node)
if conn is not None:
self.connection_dict[node.getUUID()] = conn
return conn
@profiler_decorator
def notifyFailure(self, node):
self._notifyFailure(node.getUUID(), time.time() + MAX_FAILURE_AGE)
......@@ -163,8 +151,14 @@ class ConnectionPool(object):
# Already connected to node
return self.connection_dict[uuid]
except KeyError:
if len(self.connection_dict) > self.max_pool_size:
# must drop some unused connections
self._dropConnections()
# Create new connection to node
return self._createNodeConnection(node)
conn = self._initNodeConnection(node)
if conn is not None:
self.connection_dict[uuid] = conn
return conn
finally:
self.connection_lock_release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment