don't exit when client closes

This commit is contained in:
2021-06-07 13:34:06 -04:00
parent 8a4042f95f
commit d27ad50c0e
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -864,13 +864,17 @@ def websocketupdater():
def msg_to_websockets(typ: str, msg: str):
jmsg = json.dumps({'type': typ, 'data': msg})
to_close = []
for ws in ws_connections:
try:
asyncio.run(ws.send(jmsg))
except Exception as e:
print("ws.send exception: %s" % e)
exit(1)
except Exception:
to_close.append(ws)
print("ws.send exception: closed")
for ws in to_close:
ws.close()
del ws_connections[ws]
#
# Main
#
+1 -1
View File
@@ -2,7 +2,7 @@ import asyncio
import websockets
async def hello():
uri = "ws://w02:50005/messages"
uri = "ws://localhost:50005/messages"
async with websockets.connect(uri) as websocket:
name = "Andreas"