twisted.application.internet.ClientService(service.Service, object) class documentationtwisted.application.internet
(View In Hierarchy)
A ClientService
maintains a single outgoing connection to a client endpoint, reconnecting 
after a configurable timeout when a connection fails, either before or 
after connecting.
| Present Since | 16.1.0 | |
| Method | __init__ | |
| Method | whenConnected | Retrieve the currently-connected Protocol, 
or the next one to connect. | 
| Method | startService | Start this ClientService,
initiating the connection retry loop. | 
| Method | stopService | Stop attempting to reconnect and close any existing connections. | 
Inherited from Service:
| Method | __getstate__ | Undocumented | 
| Method | setName | Set the name of the service. | 
| Method | setServiceParent | Set the parent of the service.  This method is responsible for setting 
the parentattribute on this service (the child service). | 
| Method | disownServiceParent | Use this API to remove an IServicefrom anIServiceCollection. | 
| Method | privilegedStartService | Do preparation work for starting the service. | 
| Parameters | endpoint | A stream 
client endpointprovider which will be used to connect when the 
service starts. | 
| factory | A protocol 
factorywhich will be used to create clients for the endpoint. | |
| retryPolicy | A policy configuring how long ClientServicewill wait between attempts to connect toendpoint. (type: callable taking (the number of failed connection attempts made in a row (int))
and returning the number of seconds to wait before making another attempt.) | |
| clock | The clock used to schedule reconnection.  It's mainly useful to be 
parametrized in tests.  If the factory is serialized, this attribute will 
not be serialized, and the default value (the reactor) will be restored 
when deserialized. (type: IReactorTime) | |
| prepareConnection | A single argument callablethat may return aDeferred. It 
will be called once with theprotocoleach time a new connection is made.  It may call methods on the protocol to
prepare it for use (e.g. authenticate) or validate it (check its health).The  
 Present Since Twisted 18.7.0(type: callable) | 
Retrieve the currently-connected Protocol, 
or the next one to connect.
| Parameters | failAfterFailures | number of connection failures after which the Deferred will deliver a 
Failure (None means the Deferred will only fail if/when the service is 
stopped).  Set this to 1 to make the very first connection failure signal 
an error.  Use 2 to allow one failure but signal an error if the subsequent
retry then fails. (type: intor None) | 
| Returns | a Deferred that fires with a protocol produced by the factory passed to __init__(type:Deferredthat may:
 | |
Stop attempting to reconnect and close any existing connections.
| Returns | a Deferredthat fires when all outstanding connections are closed and all in-progress 
connection attempts halted. | |