Go to the latest version of this document.

# ``twisted`.`application`.`_client_service`.`_Client``

class documentation

`class _Client(TypingProtocol): (source)`

View In Hierarchy

Undocumented

Method | `start` | Start this `ClientService`, initiating the connection retry loop.
Method | `stop` | Stop trying to connect and disconnect any current connection.
Method | `whenConnected` | Retrieve the currently-connected `Protocol`, or the next one to connect.
Method | `_clientDisconnected` | The current connection has been disconnected.
Method | `_connectionFailed` | Deliver connection failures to any `ClientService.whenConnected` `Deferred`s that have met their failAfterFailures threshold.
Method | `_connectionMade` | A connection has been made.
Method | `_reconnect` | The wait between connection attempts is done.

def start(self): (source)

Start this `ClientService`, initiating the connection retry loop.

def stop(self) -> `Deferred[None]`: (source)

Stop trying to connect and disconnect any current connection.

Returns
`Deferred[None]` | a `Deferred` that fires when all outstanding connections are closed and all in-progress connection attempts halted.

def whenConnected(self, /, failAfterFailures: `int | None` = None) -> `Deferred[IProtocol]`: (source)

Retrieve the currently-connected `Protocol`, or the next one to connect.

Parameters
failAfterFailures:`int | None` | 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.

Returns

`Deferred[IProtocol]`

a Deferred that fires with a protocol produced by the factory passed to `__init__`. It may:

- fire with `IProtocol`
- fail with `CancelledError` when the service is stopped
- fail with e.g. `DNSLookupError` or `ConnectionRefusedError` when the number of consecutive failed connection attempts equals the value of "failAfterFailures"

def _clientDisconnected(self, failure: `Failure | None` = None): (source)

The current connection has been disconnected.

def _connectionFailed(self, failure: `Failure`): (source)

Deliver connection failures to any `ClientService.whenConnected` `Deferred`s that have met their failAfterFailures threshold.

Parameters
failure:`Failure` | the Failure to fire the `Deferred`s with.

def _connectionMade(self, protocol: `_ReconnectingProtocolProxy`): (source)

A connection has been made.

Parameters
protocol:`_ReconnectingProtocolProxy` | The protocol of the connection.

def _reconnect(self, failure: `Failure | None` = None): (source)

The wait between connection attempts is done.