changeset 1210:7eb99c27a46e

Don't output the amount of transferred data when connection closed (interference with trial).
author Marcel Keller <mkeller@cs.au.dk>
date Thu, 10 Sep 2009 18:45:15 +0200
parents ec281b1151e1
children d325a4ee6625 f29e998c77c9
files viff/runtime.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Thu Sep 10 18:41:07 2009 +0200
+++ b/viff/runtime.py	Thu Sep 10 18:45:15 2009 +0200
@@ -296,8 +296,6 @@
         self.sendString(str(self.factory.runtime.id))
 
     def connectionLost(self, reason):
-        print "Transfer to peer %d: %d bytes in %d packets" % \
-              (self.peer_id, self.sent_bytes, self.sent_packets)
         reason.trap(ConnectionDone)
         self.lost_connection.callback(self)
 
@@ -586,7 +584,7 @@
 
         def close_connections(_):
             print "done."
-            print "Closing connections..."
+            print "Closing connections...",
             results = [maybeDeferred(self.port.stopListening)]
             for protocol in self.protocols.itervalues():
                 results.append(protocol.lost_connection)
@@ -594,7 +592,7 @@
             return DeferredList(results)
 
         def stop_reactor(_):
-            print "Connections closed."
+            print "done."
             print "Stopping reactor...",
             reactor.stop()
             print "done."
@@ -870,6 +868,13 @@
             self.depth_counter -= 1
             self.activation_counter = 0
 
+    def print_transferred_data():
+        """Print the amount of transferred data for all connections."""
+
+        for protocol in self.protocols.itervalues():
+            print "Transfer to peer %d: %d bytes in %d packets" % \
+                  (protocol.peer_id, protocol.sent_bytes, protocol.sent_packets)
+
 
 def make_runtime_class(runtime_class=None, mixins=None):
     """Creates a new runtime class with *runtime_class* as a base