[Neo-report] r2056 gregory - in /trunk/neo: ./ master/ master/handlers/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Apr 30 15:48:09 CEST 2010
Author: gregory
Date: Fri Apr 30 15:48:08 2010
New Revision: 2056
Log:
Add __repr__ to Connection.
Modified:
trunk/neo/connection.py
trunk/neo/handler.py
trunk/neo/master/app.py
trunk/neo/master/handlers/election.py
trunk/neo/master/verification.py
Modified: trunk/neo/connection.py
==============================================================================
--- trunk/neo/connection.py [iso-8859-1] (original)
+++ trunk/neo/connection.py [iso-8859-1] Fri Apr 30 15:48:08 2010
@@ -238,13 +238,12 @@
if handlers.isPending():
msg_id = handlers.checkTimeout(t)
if msg_id is not None:
- logging.info('timeout for %r with %s:%d', msg_id,
- *self.getAddress())
+ logging.info('timeout for %r with %r', msg_id, self)
self.close()
self.getHandler().timeoutExpired(self)
elif self._timeout.hardExpired(t):
# critical time reach or pong not received, abort
- logging.info('timeout with %s:%d', *(self.getAddress()))
+ logging.info('timeout with %r', self)
self.notify(Packets.Notify('Timeout'))
self.abort()
self.getHandler().timeoutExpired(self)
@@ -280,6 +279,16 @@
self.connector.shutdown()
self.connector.close()
self.connector = None
+
+ def __repr__(self):
+ address = self.addr and '%s:%d' % self.addr or '?'
+ return '<%s(uuid=%s, address=%s, closed=%s) at %x>' % (
+ self.__class__.__name__,
+ dump(self.getUUID()),
+ address,
+ self.isClosed(),
+ id(self),
+ )
__del__ = close
@@ -395,8 +404,7 @@
return next_id
def close(self):
- logging.debug('closing a connector for %s (%s:%d)',
- dump(self.uuid), *(self.addr))
+ logging.debug('closing a connector for %r', self)
BaseConnection.close(self)
if self._on_close is not None:
self._on_close()
@@ -407,8 +415,7 @@
def abort(self):
"""Abort dealing with this connection."""
- logging.debug('aborting a connector for %s (%s:%d)',
- dump(self.uuid), *(self.addr))
+ logging.debug('aborting a connector for %r', self)
self.aborted = True
def writable(self):
Modified: trunk/neo/handler.py
==============================================================================
--- trunk/neo/handler.py [iso-8859-1] (original)
+++ trunk/neo/handler.py [iso-8859-1] Fri Apr 30 15:48:08 2010
@@ -58,7 +58,7 @@
except UnexpectedPacketError, e:
self.__unexpectedPacket(conn, packet, *e.args)
except PacketMalformedError:
- logging.error('malformed packet from %s:%d', *(conn.getAddress()))
+ logging.error('malformed packet from %r', conn)
conn.notify(Packets.Notify('Malformed packet: %r' % (packet, )))
conn.abort()
self.peerBroken(conn)
@@ -91,32 +91,32 @@
def connectionStarted(self, conn):
"""Called when a connection is started."""
- logging.debug('connection started for %s:%d', *(conn.getAddress()))
+ logging.debug('connection started for %r', conn)
def connectionCompleted(self, conn):
"""Called when a connection is completed."""
- logging.debug('connection completed for %s:%d', *(conn.getAddress()))
+ logging.debug('connection completed for %r', conn)
def connectionFailed(self, conn):
"""Called when a connection failed."""
- logging.debug('connection failed for %s:%d', *(conn.getAddress()))
+ logging.debug('connection failed for %r', conn)
def connectionAccepted(self, conn):
"""Called when a connection is accepted."""
def timeoutExpired(self, conn):
"""Called when a timeout event occurs."""
- logging.debug('timeout expired for %s:%d', *(conn.getAddress()))
+ logging.debug('timeout expired for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def connectionClosed(self, conn):
"""Called when a connection is closed by the peer."""
- logging.debug('connection closed for %s:%d', *(conn.getAddress()))
+ logging.debug('connection closed for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def peerBroken(self, conn):
"""Called when a peer is broken."""
- logging.error('%s:%d is broken', *(conn.getAddress()))
+ logging.error('%r is broken', conn)
self.connectionLost(conn, NodeStates.BROKEN)
def connectionLost(self, conn, new_state):
@@ -128,7 +128,7 @@
# Packet handlers.
def notify(self, conn, message):
- logging.info('notification from %s:%d: %s', *(conn.getAddress(), message))
+ logging.info('notification from %r: %s', conn, message)
def requestIdentification(self, conn, node_type,
uuid, address, name):
Modified: trunk/neo/master/app.py
==============================================================================
--- trunk/neo/master/app.py [iso-8859-1] (original)
+++ trunk/neo/master/app.py [iso-8859-1] Fri Apr 30 15:48:08 2010
@@ -350,8 +350,7 @@
return
def playPrimaryRole(self):
- logging.info('play the primary role with %s (%s:%d)',
- dump(self.uuid), *(self.server))
+ logging.info('play the primary role with %r', self.listening_conn)
# i'm the primary, send the announcement
self._announcePrimary()
@@ -388,8 +387,7 @@
"""
I play a secondary role, thus only wait for a primary master to fail.
"""
- logging.info('play the secondary role with %s (%s:%d)',
- dump(self.uuid), *(self.server))
+ logging.info('play the secondary role with %r', self.listening_conn)
# Wait for an announcement. If this is too long, probably
# the primary master is down.
Modified: trunk/neo/master/handlers/election.py
==============================================================================
--- trunk/neo/master/handlers/election.py [iso-8859-1] (original)
+++ trunk/neo/master/handlers/election.py [iso-8859-1] Fri Apr 30 15:48:08 2010
@@ -90,7 +90,7 @@
node = app.nm.getByAddress(conn.getAddress())
if node_type != NodeTypes.MASTER:
# The peer is not a master node!
- logging.error('%s:%d is not a master node', *conn.getAddress())
+ logging.error('%r is not a master node', conn)
app.nm.remove(node)
app.negotiating_master_node_set.discard(node.getAddress())
conn.close()
Modified: trunk/neo/master/verification.py
==============================================================================
--- trunk/neo/master/verification.py [iso-8859-1] (original)
+++ trunk/neo/master/verification.py [iso-8859-1] Fri Apr 30 15:48:08 2010
@@ -190,8 +190,7 @@
def answerUnfinishedTransactions(self, conn, tid_list):
uuid = conn.getUUID()
- logging.info('got unfinished transactions %s from %s:%d',
- tid_list, *(conn.getAddress()))
+ logging.info('got unfinished transactions %s from %r', tid_list, conn)
if self._uuid_dict.get(uuid, True):
# No interest.
return
More information about the Neo-report
mailing list