Merge pull request #971 from pcinkh/socket_disconnects_speedup
Critical speedup websocket disconnects from O(N) to O(1)
This commit is contained in:
commit
d4bb14a511
|
@ -54,7 +54,7 @@ class Sanic:
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
self.is_request_stream = False
|
self.is_request_stream = False
|
||||||
self.websocket_enabled = False
|
self.websocket_enabled = False
|
||||||
self.websocket_tasks = []
|
self.websocket_tasks = set()
|
||||||
|
|
||||||
# Register alternative method names
|
# Register alternative method names
|
||||||
self.go_fast = self.run
|
self.go_fast = self.run
|
||||||
|
@ -259,7 +259,7 @@ class Sanic:
|
||||||
# its future is kept in self.websocket_tasks in case it
|
# its future is kept in self.websocket_tasks in case it
|
||||||
# needs to be cancelled due to the server being stopped
|
# needs to be cancelled due to the server being stopped
|
||||||
fut = ensure_future(handler(request, ws, *args, **kwargs))
|
fut = ensure_future(handler(request, ws, *args, **kwargs))
|
||||||
self.websocket_tasks.append(fut)
|
self.websocket_tasks.add(fut)
|
||||||
try:
|
try:
|
||||||
await fut
|
await fut
|
||||||
except (CancelledError, ConnectionClosed):
|
except (CancelledError, ConnectionClosed):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user