gs: more error catching

This commit is contained in:
Laila van Reenen 2024-08-15 14:57:11 +02:00
parent 5beb79b51b
commit 3cda1316ae
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769

View File

@ -209,6 +209,7 @@ async def new_boat(boatId, name, ws):
async def run(ws, path): async def run(ws, path):
"""hadeler for every new websocket connection""" """hadeler for every new websocket connection"""
client = None client = None
try:
async for msg in ws: async for msg in ws:
for message in msg.split("\n"): for message in msg.split("\n"):
if len(message) == 0: if len(message) == 0:
@ -249,6 +250,8 @@ async def run(ws, path):
print("INFO: boat " + client['id'] + ": disconnected") print("INFO: boat " + client['id'] + ": disconnected")
client['state'] = "terminated" client['state'] = "terminated"
break break
except websockets.exceptions.ConnectionClosed:
print("INFO: connection disconected")
async def main(): async def main():
"""main""" """main"""