From 6d2f5da5063ca0285d879d8b8fada42023f9786c Mon Sep 17 00:00:00 2001 From: pcinkh Date: Wed, 11 Oct 2017 14:02:26 +0300 Subject: [PATCH] Speedup websocket disconnects. --- sanic/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index 8f1e0b90..8f70b6e7 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -54,7 +54,7 @@ class Sanic: self.is_running = False self.is_request_stream = False self.websocket_enabled = False - self.websocket_tasks = [] + self.websocket_tasks = set() # Register alternative method names self.go_fast = self.run @@ -259,7 +259,7 @@ class Sanic: # its future is kept in self.websocket_tasks in case it # needs to be cancelled due to the server being stopped fut = ensure_future(handler(request, ws, *args, **kwargs)) - self.websocket_tasks.append(fut) + self.websocket_tasks.add(fut) try: await fut except (CancelledError, ConnectionClosed):