websockets: minor fixes
When a websocket is closed, set "is_closed" to True in the on_closed handler. When closing all websockets, iterate through a list of values. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
87e136003f
commit
ab6ed40bcb
|
@ -252,7 +252,7 @@ class WebsocketManager:
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
async with self.ws_lock:
|
async with self.ws_lock:
|
||||||
for ws in self.websockets.values():
|
for ws in list(self.websockets.values()):
|
||||||
ws.close()
|
ws.close()
|
||||||
self.websockets = {}
|
self.websockets = {}
|
||||||
|
|
||||||
|
@ -297,6 +297,7 @@ class WebSocket(WebSocketHandler):
|
||||||
f"Error sending data over websocket: {self.uid}")
|
f"Error sending data over websocket: {self.uid}")
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
|
self.is_closed = True
|
||||||
io_loop = IOLoop.current()
|
io_loop = IOLoop.current()
|
||||||
io_loop.spawn_callback(self.wsm.remove_websocket, self)
|
io_loop.spawn_callback(self.wsm.remove_websocket, self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue