Commit 1d4c4825 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Delete outer loop, at most one iteration could happpen.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2575 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 3149c554
......@@ -58,45 +58,41 @@ class ConnectionPool(object):
return None
app = self.app
app.setNodeReady()
neo.logging.debug('trying to connect to %s - %s', node,
node.getState())
conn = MTClientConnection(app.em, app.storage_event_handler, addr,
connector=app.connector_handler(), dispatcher=app.dispatcher)
conn.lock()
# Loop until a connection is obtained.
while True:
neo.logging.debug('trying to connect to %s - %s', node,
node.getState())
app.setNodeReady()
conn = MTClientConnection(app.em,
app.storage_event_handler, addr,
connector=app.connector_handler(), dispatcher=app.dispatcher)
conn.lock()
try:
if conn.getConnector() is None:
# This happens, if a connection could not be established.
neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
p = Packets.RequestIdentification(NodeTypes.CLIENT,
app.uuid, None, app.name)
msg_id = conn.ask(p, queue=app.local_var.queue)
finally:
conn.unlock()
try:
app._waitMessage(conn, msg_id,
handler=app.storage_bootstrap_handler)
except ConnectionClosed:
try:
if conn.getConnector() is None:
# This happens, if a connection could not be established.
neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
if app.isNodeReady():
neo.logging.info('Connected %r', node)
return conn
else:
neo.logging.info('%r not ready', node)
self.notifyFailure(node)
return None
p = Packets.RequestIdentification(NodeTypes.CLIENT,
app.uuid, None, app.name)
msg_id = conn.ask(p, queue=app.local_var.queue)
finally:
conn.unlock()
try:
app._waitMessage(conn, msg_id,
handler=app.storage_bootstrap_handler)
except ConnectionClosed:
neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
if app.isNodeReady():
neo.logging.info('Connected %r', node)
return conn
else:
neo.logging.info('%r not ready', node)
self.notifyFailure(node)
return None
@profiler_decorator
def _dropConnections(self):
......
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