Commit 6760a4a0 authored by Vincent Pelletier's avatar Vincent Pelletier

Make Dispatcher.registered locally compute key value from connection, so that...

Make Dispatcher.registered locally compute key value from connection, so that it is easier to change the way key is computed.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@268 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 6d3fa754
...@@ -108,7 +108,7 @@ class ConnectionPool(object): ...@@ -108,7 +108,7 @@ class ConnectionPool(object):
conn.lock() conn.lock()
try: try:
if not conn.pending() and \ if not conn.pending() and \
not self.app.dispatcher.registered(id(conn)): not self.app.dispatcher.registered(conn):
del self.connection_dict[conn.getUUID()] del self.connection_dict[conn.getUUID()]
conn.close() conn.close()
logging.info('_dropConnections : connection to storage node %s:%d closed', logging.info('_dropConnections : connection to storage node %s:%d closed',
......
...@@ -53,10 +53,11 @@ class Dispatcher(Thread): ...@@ -53,10 +53,11 @@ class Dispatcher(Thread):
key = (id(conn), msg_id) key = (id(conn), msg_id)
self.message_table[key] = queue self.message_table[key] = queue
def registered(self, id): def registered(self, conn):
"""Check if a connection is registered into message table.""" """Check if a connection is registered into message table."""
searched_id = id(conn)
for conn_id, msg_id in self.message_table.iterkeys(): for conn_id, msg_id in self.message_table.iterkeys():
if id == conn_id: if searched_id == conn_id:
return True return True
return False return False
......
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