cheroot.connections module

Utilities to manage open connections.

class cheroot.connections.ConnectionManager(server)

Bases: object

Class which manages HTTPConnection objects.

This is for connections which are being kept-alive for follow-up requests.

property _num_connections

Return the current number of connections.

Includes any in the readable list or registered with the selector, minus one for the server socket, which is always registered with the selector.

property can_add_keepalive_connection

Flag whether it is allowed to add a new keep-alive connection.


Close all monitored connections.


Expire least recently used connections.

This happens if there are either too many open connections, or if the connections have been timed out.

This should be called periodically.


Return a HTTPConnection object which is ready to be handled.

A connection returned by this method should be ready for a worker to handle it. If there are no connections ready, None will be returned.

Any connection returned by this method will need to be put back if it should be examined again for another request.


HTTPConnection instance, or None

Return type



Put idle connection into the ConnectionManager to be managed.


conn (cheroot.server.HTTPConnection) – HTTP connection to be managed


Mark the given socket fd as non-inheritable (POSIX).