t.w.c.HTTPConnectionPool(object) : class documentation

Part of twisted.web.client View Source View In Hierarchy

A pool of persistent HTTP connections.

Features:

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 Since12.1
Instance Variable persistent Boolean indicating whether connections should be persistent. Connections are persistent by default.
Instance Variable maxPersistentPerHost The maximum number of cached persistent connections for a host:port destination. (type: int)
Instance Variable cachedConnectionTimeout Number of seconds a cached persistent connection will stay open before disconnecting.
Instance Variable retryAutomatically boolean indicating whether idempotent requests should be retried once if no response was received.
Method __init__ Undocumented
Method getConnection Retrieve a connection, either new or cached, to be used for a HTTP request.
Method closeCachedConnections Close all persistent connections and remove them from the pool.
Instance Variable _factory The factory used to connect to the proxy.
Instance Variable _connections Map (scheme, host, port) to lists of HTTP11ClientProtocol instances.
Instance Variable _timeouts Map HTTP11ClientProtocol instances to a IDelayedCall instance of their timeout.
Method _newConnection Create a new connection.
Method _removeConnection Remove a connection from the cache and disconnect it.
Method _putConnection Return a persistent connection to the pool. This will be called by HTTP11ClientProtocol when the connection becomes quiescent.
persistent =
Boolean indicating whether connections should be persistent. Connections are persistent by default.
maxPersistentPerHost =
The maximum number of cached persistent connections for a host:port destination. (type: int)
cachedConnectionTimeout =
Number of seconds a cached persistent connection will stay open before disconnecting.
retryAutomatically =
boolean indicating whether idempotent requests should be retried once if no response was received.
_factory =
The factory used to connect to the proxy.
_connections =
Map (scheme, host, port) to lists of HTTP11ClientProtocol instances.
_timeouts =
Map HTTP11ClientProtocol instances to a IDelayedCall instance of their timeout.
def __init__(self, reactor, persistent=True): (source)
Undocumented
def getConnection(self, key, endpoint): (source)
Retrieve a connection, either new or cached, to be used for a HTTP request.

If a cached connection is returned, it will not be used for other requests until it is put back (which will happen automatically), since we do not support pipelined requests. If no cached connection is available, the passed in endpoint is used to create the connection.

If the connection doesn't disconnect at the end of its request, it will be returned to this pool automatically. As such, only a single request should be sent using the returned connection.

ParameterskeyA unique key identifying connections that can be used interchangeably.
endpointAn endpoint that can be used to open a new connection if no cached connection is available.
ReturnsA Deferred that will fire with a HTTP11ClientProtocol (or a wrapper) that can be used to send a single HTTP request.
def _newConnection(self, key, endpoint): (source)
Create a new connection.

This implements the new connection code path for getConnection.

def _removeConnection(self, key, connection): (source)
Remove a connection from the cache and disconnect it.
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 closeCachedConnections(self): (source)
Close all persistent connections and remove them from the pool.
Returnsdefer.Deferred that fires when all connections have been closed.
API Documentation for Twisted, generated by pydoctor at 2012-09-01 11:44:56.