viff

changeset 830:a7fba43c2c6a

Make players attempt to reconnect if connection fails. It is only if the initial connection fails that they will reconnect, if the connection fails in the middle of a protocol run they will still crash. This is probably the right thing to do since we generally wouldn't know how to recover from a crashed protocol. This allows the players to be started in any order and is thus a fix for Issue 8.
author Martin Geisler <mg@daimi.au.dk>
date Sun, 13 Jul 2008 23:38:22 +0200
parents 405569e5cb96
children 889882a2798b
files viff/runtime.py
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Sun Jul 13 17:04:42 2008 +0200
     1.2 +++ b/viff/runtime.py	Sun Jul 13 23:38:22 2008 +0200
     1.3 @@ -48,7 +48,7 @@
     1.4  from twisted.internet.error import ConnectionDone
     1.5  from twisted.internet.defer import Deferred, DeferredList, gatherResults, succeed
     1.6  from twisted.internet.defer import maybeDeferred
     1.7 -from twisted.internet.protocol import ClientFactory, ServerFactory
     1.8 +from twisted.internet.protocol import ReconnectingClientFactory, ServerFactory
     1.9  from twisted.protocols.basic import Int16StringReceiver
    1.10  
    1.11  
    1.12 @@ -319,7 +319,7 @@
    1.13          self.transport.loseConnection()
    1.14  
    1.15  
    1.16 -class ShareExchangerFactory(ServerFactory, ClientFactory):
    1.17 +class ShareExchangerFactory(ReconnectingClientFactory, ServerFactory):
    1.18      """Factory for creating ShareExchanger protocols."""
    1.19  
    1.20      protocol = ShareExchanger
    1.21 @@ -340,8 +340,6 @@
    1.22      def clientConnectionLost(self, connector, reason):
    1.23          reason.trap(ConnectionDone)
    1.24  
    1.25 -    def clientConnectionFailed(self, connector, reason):
    1.26 -        print "Client connection failed:", reason
    1.27          
    1.28  def increment_pc(method):
    1.29      """Make *method* automatically increment the program counter.