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

Class ReconnectingClientFactory

  Factory --+    
            |    
ClientFactory --+
                |
               ReconnectingClientFactory

Known Subclasses:
TendrilFactory

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

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

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

Class Variable Summary
NoneType connector
float delay
float factor
float initialDelay
float jitter
int maxDelay
NoneType maxRetries
int retries
NoneType _callID

Method Details

clientConnectionFailed(self, connector, reason)

Called when a connection has failed.

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

initialDelay

Delay for the first reconnection attempt.

jitter

percentage of randomness to introduce into the delay lengh to prevent stampeding.

maxDelay

Maximum number of seconds between connection attempts.

Class Variable Details

connector

Type:
NoneType
Value:
None                                                                   

delay

Type:
float
Value:
1.0                                                                    

factor

Type:
float
Value:
2.7182818284590451                                                     

initialDelay

Type:
float
Value:
1.0                                                                    

jitter

Type:
float
Value:
0.11962656492                                                          

maxDelay

Type:
int
Value:
3600                                                                   

maxRetries

Type:
NoneType
Value:
None                                                                   

retries

Type:
int
Value:
0                                                                      

_callID

Type:
NoneType
Value:
None                                                                   

Generated by Epydoc 1.2 prerelease on Wed Jan 29 06:28:14 2003 http://epydoc.sf.net