Skip to content

Commit

Permalink
CustomServer: cleanup exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Sep 10, 2023
1 parent f33b583 commit de073d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WebHostLib/customserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def main():
ctx.server = websockets.serve(functools.partial(server, ctx=ctx), ctx.host, ctx.port, ssl=ssl_context)

await ctx.server
except Exception: # likely port in use - in windows this is OSError, but I didn't check the others
except OSError: # likely port in use
ctx.server = websockets.serve(functools.partial(server, ctx=ctx), ctx.host, 0, ssl=ssl_context)

await ctx.server
Expand Down Expand Up @@ -205,12 +205,12 @@ async def main():
with Locker(room_id):
try:
asyncio.run(main())
except KeyboardInterrupt:
except (KeyboardInterrupt, SystemExit):
with db_session:
room = Room.get(id=room_id)
# ensure the Room does not spin up again on its own, minute of safety buffer
room.last_activity = datetime.datetime.utcnow() - datetime.timedelta(minutes=1, seconds=room.timeout)
except:
except Exception:
with db_session:
room = Room.get(id=room_id)
room.last_port = -1
Expand Down

0 comments on commit de073d6

Please sign in to comment.