Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`web`.`client`.`HTTPConnectionPool``

class documentation

`class HTTPConnectionPool: (source)`

View In Hierarchy

A pool of persistent HTTP connections.

Features:

- Cached connections will eventually time out.
- Limits on maximum number of persistent connections.

Connections are stored using keys, which should be chosen such that any connections stored under a given key can be used interchangeably.

Failed requests done using previously cached connections will be retried once if they use an idempotent method (e.g. GET), in case the HTTP server timed them out.

Present Since
12.1

Method | `__init__` | Undocumented
Method | `closeCachedConnections` | Close all persistent connections and remove them from the pool.
Method | `getConnection` | Supply a connection, newly created or retrieved from the pool, to be used for one HTTP request.
Instance Variable | `cachedConnectionTimeout` | Number of seconds a cached persistent connection will stay open before disconnecting.
Instance Variable | `maxPersistentPerHost` | The maximum number of cached persistent connections for a `host:port` destination.
Instance Variable | `persistent` | Boolean indicating whether connections should be persistent. Connections are persistent by default.
Instance Variable | `retryAutomatically` | `boolean` indicating whether idempotent requests should be retried once if no response was received.
Method | `_newConnection` | Create a new connection.
Method | `_putConnection` | Return a persistent connection to the pool. This will be called by `HTTP11ClientProtocol` when the connection becomes quiescent.
Method | `_removeConnection` | Remove a connection from the cache and disconnect it.
Class Variable | `_log` | Undocumented
Instance Variable | `_connections` | Map (scheme, host, port) to lists of `HTTP11ClientProtocol` instances.
Instance Variable | `_factory` | The factory used to connect to the proxy.
Instance Variable | `_reactor` | Undocumented
Instance Variable | `_timeouts` | Map `HTTP11ClientProtocol` instances to a `IDelayedCall` instance of their timeout.

def __init__(self, reactor, persistent=True): (source)

Undocumented

def closeCachedConnections(self): (source)

Close all persistent connections and remove them from the pool.

Returns
`defer.Deferred` that fires when all connections have been closed.

def getConnection(self, key, endpoint): (source)

Supply a connection, newly created or retrieved from the pool, to be used for one HTTP request.

The connection will remain out of the pool (not available to be returned from future calls to this method) until one HTTP request has been completed over it.

Afterwards, if the connection is still open, it will automatically be added to the pool.

Parameters
key | A unique key identifying connections that can be used interchangeably.
endpoint | An endpoint that can be used to open a new connection if no cached connection is available.
Returns
A `Deferred` that will fire with a `HTTP11ClientProtocol` (or a wrapper) that can be used to send a single HTTP request.

cachedConnectionTimeout: `int` = (source)

Number of seconds a cached persistent connection will stay open before disconnecting.

maxPersistentPerHost: `int` = (source)

The maximum number of cached persistent connections for a `host:port` destination.

persistent = (source)

Boolean indicating whether connections should be persistent. Connections are persistent by default.

retryAutomatically: `bool` = (source)

`boolean` indicating whether idempotent requests should be retried once if no response was received.

def _newConnection(self, key, endpoint): (source)

Create a new connection.

This implements the new connection code path for `getConnection`.

def _putConnection(self, key, connection): (source)

Return a persistent connection to the pool. This will be called by `HTTP11ClientProtocol` when the connection becomes quiescent.

def _removeConnection(self, key, connection): (source)

Remove a connection from the cache and disconnect it.

_log = (source)

Undocumented

_connections: `dict` = (source)

Map (scheme, host, port) to lists of `HTTP11ClientProtocol` instances.

_factory = (source)

The factory used to connect to the proxy.

_reactor = (source)

Undocumented

_timeouts: `dict` = (source)

Map `HTTP11ClientProtocol` instances to a `IDelayedCall` instance of their timeout.