Merge pull request #171 from jpiasetz/convert_dict_to_set
Convert connections dict to set
This commit is contained in:
commit
35e79f3985
|
@ -60,14 +60,14 @@ class HttpProtocol(asyncio.Protocol):
|
|||
# -------------------------------------------- #
|
||||
|
||||
def connection_made(self, transport):
|
||||
self.connections[self] = True
|
||||
self.connections.add(self)
|
||||
self._timeout_handler = self.loop.call_later(
|
||||
self.request_timeout, self.connection_timeout)
|
||||
self.transport = transport
|
||||
self._last_request_time = current_time
|
||||
|
||||
def connection_lost(self, exc):
|
||||
del self.connections[self]
|
||||
self.connections.discard(self)
|
||||
self._timeout_handler.cancel()
|
||||
self.cleanup()
|
||||
|
||||
|
@ -250,7 +250,7 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
|||
|
||||
trigger_events(before_start, loop)
|
||||
|
||||
connections = {}
|
||||
connections = set()
|
||||
signal = Signal()
|
||||
server = partial(
|
||||
HttpProtocol,
|
||||
|
@ -301,7 +301,7 @@ def serve(host, port, request_handler, error_handler, before_start=None,
|
|||
|
||||
# Complete all tasks on the loop
|
||||
signal.stopped = True
|
||||
for connection in connections.keys():
|
||||
for connection in connections:
|
||||
connection.close_if_idle()
|
||||
|
||||
while connections:
|
||||
|
|
Loading…
Reference in New Issue
Block a user