Package twisted :: Package internet :: Module protocol :: Class ReconnectingClientFactory
[frames | no frames]

Class ReconnectingClientFactory

  Factory --+    
            |    
ClientFactory --+
                |
               ReconnectingClientFactory

Known Subclasses:
ReconnectingPBClientFactory

My clients auto-reconnect with an exponential back-off.

Note that clients should call my resetDelay method after they have connected successfully.
Method Summary
  clientConnectionFailed(self, connector, reason)
Called when a connection has failed to connect.
  clientConnectionLost(self, connector, unused_reason)
  resetDelay(self)
Call me after a successful connection to reset.
  retry(self, connector)
Have this connector connect again, after a suitable delay.
  stopTrying(self)
I put a stop to any attempt to reconnect in progress.
    Inherited from ClientFactory
  startedConnecting(self, connector)
Called when a connection has been started.
    Inherited from Factory
  buildProtocol(self, addr)
Create an instance of a subclass of Protocol.
  doStart(self)
Make sure startFactory is called.
  doStop(self)
Make sure stopFactory is called.
  startFactory(self)
This will be called before I begin listening on a Port or Connector.
  stopFactory(self)
This will be called before I stop listening on all Ports/Connectors.

Instance Variable Summary
float factor: a multiplicitive factor by which the delay grows
float initialDelay: Delay for the first reconnection attempt.
float jitter: percentage of randomness to introduce into the delay length to prevent stampeding.
int maxDelay: Maximum number of seconds between connection attempts.

Class Variable Summary
NoneType connector = None                                                                  
int continueTrying = 1                                                                     
float delay = 1.0                                                                   
NoneType maxRetries = None                                                                  
int retries = 0                                                                     
    Inherited from Factory
Implements __implemented__ = <implementedBy twisted.internet.protoc...
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
bool noisy = True
int numPorts = 0                                                                     
NoneType protocol = None                                                                  

Method Details

clientConnectionFailed(self, connector, reason)

Called when a connection has failed to connect.

It may be useful to call connector.connect() - this will reconnect.
Parameters:
reason
           (type=twisted.python.failure.Failure)
Overrides:
twisted.internet.protocol.ClientFactory.clientConnectionFailed (inherited documentation)

resetDelay(self)

Call me after a successful connection to reset.

I reset the delay and the retry counter.

retry(self, connector=None)

Have this connector connect again, after a suitable delay.

stopTrying(self)

I put a stop to any attempt to reconnect in progress.

Instance Variable Details

factor

a multiplicitive factor by which the delay grows
Type:
float
Value:
2.7182818284590451                                                    

initialDelay

Delay for the first reconnection attempt.
Type:
float
Value:
1.0                                                                   

jitter

percentage of randomness to introduce into the delay length to prevent stampeding.
Type:
float
Value:
0.11962656492                                                         

maxDelay

Maximum number of seconds between connection attempts.
Type:
int
Value:
3600                                                                  

Class Variable Details

connector

Type:
NoneType
Value:
None                                                                  

continueTrying

Type:
int
Value:
1                                                                     

delay

Type:
float
Value:
1.0                                                                   

maxRetries

Type:
NoneType
Value:
None                                                                  

retries

Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1 on Sun Dec 10 22:04:45 2006 http://epydoc.sf.net