# find an un-used connection for this host
connection = next(
(conn for conn in connections if not conn.in_use), None)
# find an un-used connection for this host
connection = next(
(conn for conn in connections if not conn.in_use), None)
if connection is None:
# disconnect the least-recently-used un-used connection to make space
# for a new connection. There will be at least one.
if connection is None:
# disconnect the least-recently-used un-used connection to make space
# for a new connection. There will be at least one.
connection = Connection(self, host, reader, writer)
await connection._hello()
connections.append(connection)
connection = Connection(self, host, reader, writer)
await connection._hello()
connections.append(connection)
"""Close all connections"""
connections = [c for cs in self._connections.values() for c in cs]
self._connections = OrderedDict()
"""Close all connections"""
connections = [c for cs in self._connections.values() for c in cs]
self._connections = OrderedDict()