Package CyberRail :: Package common :: Module httpclient :: Class ConnectionsPool
[hide private]
[frames] | no frames]

Class ConnectionsPool

source code


Manage connections to hosts requested by the http client. The manager is responsible to keep alive connections, in order to reuse them when possible.

It also keeps track of the number of connection per host/port, in order to conforme to RFC 2616 chapt 8.1.4 last §. It is so able to hald a request until a connection has been maid free (either by closing it or by releasing it)

Instance Methods [hide private]
 
__init__(self, communicationManager)
Construct an HTTP Connection Pool.
source code
 
_onEvent(self, event)
Called when an event is received from the communication manager.
source code
 
_manageErroneousConnection(self, cid, msg)
Error event management.
source code
 
_manageReadyConnection(self, cid)
Connection is ready to be used (when just opened)
source code
 
_removeClosedConnection(self, cid)
Connection has been closed, so remove it from the pool.
source code
 
getKey(self, host, port)
Return an unique key, given an host and a port
source code
 
requestConnection(self, host, port, ssl, callback, errorCallback)
Ask for the pool manager to enable a connection suitable for an HTTP Request.
source code
 
_managePendingRequests(self)
Manage pending request given the actual state of the connection pool.
source code
 
_createConnection(self, host, port, ssl)
Create a new TCP connection.
source code
 
releaseValidConnection(self, con, newTimeout)
Release the connection.
source code
 
setHostVersion(self, host, port, version)
Set the HTTP version of the server software.
source code
 
getHostVersion(self, host, port)
Get the HTTP version of the server software.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, communicationManager)
(Constructor)

source code 

Construct an HTTP Connection Pool.

Parameters:
  • communicationManager - the communicationManager that will gives us the TCP connections.
Overrides: object.__init__

_onEvent(self, event)

source code 

Called when an event is received from the communication manager. Dispatch this event to the proper handler given the event.

_manageErroneousConnection(self, cid, msg)

source code 

Error event management. Call the error callback.

requestConnection(self, host, port, ssl, callback, errorCallback)

source code 

Ask for the pool manager to enable a connection suitable for an HTTP Request. This call is asynchronous. If possible, another TCP connection will be used, or if possible, a new connection will be established, or the request will be kept hold if all the connection for this host are busy.

Parameters:
  • host - the host to connect to
  • port - the port to connect to
  • callback - called when the connection becomes available
  • errorCallback - called when IO errors arise (not HTTP errors)

releaseValidConnection(self, con, newTimeout)

source code 

Release the connection. Do not call this if the connection has been closed, since the cid is now invalid (and has perhaps already been set to another connection)

Note: The connection Pool has its own mechanism to handle closed connections.