Package buildbot :: Module pbutil :: Class ReconnectingPBClientFactory
[frames | no frames]

Class ReconnectingPBClientFactory

          Factory --+        
                    |        
        ClientFactory --+    
                        |    
          PBClientFactory --+
                            |
          Factory --+       |
                    |       |
        ClientFactory --+   |
                        |   |
ReconnectingClientFactory --+
                            |
                           ReconnectingPBClientFactory

Known Subclasses:
BotFactory

Reconnecting client factory for PB brokers.

Like PBClientFactory, but if the connection fails or is lost, the factory will attempt to reconnect.

Instead of using f.getRootObject (which gives a Deferred that can only be fired once), override the gotRootObject method.

Instead of using the newcred f.login (which is also one-shot), call f.startLogin() with the credentials and client, and override the gotPerspective method.

Instead of using the oldcred f.getPerspective (also one-shot), call f.startGettingPerspective() with the same arguments, and override gotPerspective.

gotRootObject and gotPerspective will be called each time the object is received (once per successful connection attempt). You will probably want to use obj.notifyOnDisconnect to find out when the connection is lost.

If an authorization error occurs, failedToGetPerspective() will be invoked.

To use me, subclass, then hand an instance to a connector (like TCPClient).
Method Summary
  __init__(self)
  __getstate__(self)
  clientConnectionFailed(self, connector, reason)
Called when a connection has failed to connect.
  clientConnectionLost(self, connector, reason)
  clientConnectionMade(self, broker)
  doGetPerspective(self, root)
  doLogin(self, root)
  failedToGetPerspective(self, why)
The login process failed, most likely because of an authorization failure (bad password), but it is also possible that we lost the new connection before we managed to send our credentials.
  getPerspective(self, *args)
  gotPerspective(self, perspective)
The remote avatar or perspective (obtained each time this factory connects) is now available.
  gotRootObject(self, root)
The remote root object (obtained each time this factory connects) is now available.
  login(self, *args)
  startGettingPerspective(self, username, password, serviceName, perspectiveName, client)
  startLogin(self, credentials, client)
    Inherited from PBClientFactory
  disconnect(self)
If the factory is connected, close the connection.
  getRootObject(self)
Get root object of remote PB server.
    Inherited from ReconnectingClientFactory
  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
    Inherited from ReconnectingClientFactory
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
    Inherited from PBClientFactory
int unsafeTracebacks = 0                                                                     
    Inherited from ReconnectingClientFactory
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.spread.pb.PBClientFactory.clientConnectionFailed (inherited documentation)

failedToGetPerspective(self, why)

The login process failed, most likely because of an authorization failure (bad password), but it is also possible that we lost the new connection before we managed to send our credentials.

gotPerspective(self, perspective)

The remote avatar or perspective (obtained each time this factory connects) is now available.

gotRootObject(self, root)

The remote root object (obtained each time this factory connects) is now available. This method will be called each time the connection is established and the object reference is retrieved.

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