Fix #57 - Errors when a socket is not properly closed
This commit is contained in:
parent
0d3a57794f
commit
4b67e0a6f2
1 changed files with 11 additions and 1 deletions
|
@ -135,8 +135,18 @@ def getWebSocketHandler(central_command):
|
|||
logger.critical("Tried to send 'none' to Panopticon")
|
||||
return
|
||||
|
||||
toRemove = []
|
||||
for client in wsHandlerClass.connections:
|
||||
try:
|
||||
client.write_message(msg)
|
||||
except tornado.websocket.WebSocketClosedError as e:
|
||||
logger.warning(f"Not properly closed websocket connection")
|
||||
toRemove.append(client) # If we remove it here from the set we get an exception about changing set size during iteration
|
||||
|
||||
for client in toRemove:
|
||||
if client not in wsHandlerClass.connections:
|
||||
continue
|
||||
wsHandlerClass.connections.remove(client)
|
||||
|
||||
return WebSocketHandler
|
||||
|
||||
|
|
Loading…
Reference in a new issue