diff --git a/sanic/server.py b/sanic/server.py index ef9869d2..a86da9fc 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -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: