Server: handle SIGINT

This commit is contained in:
Lexi / Zoe 2018-11-24 01:46:44 +01:00
parent d5f1e76383
commit 635b44fff3
1 changed files with 8 additions and 2 deletions

View File

@ -58,5 +58,11 @@ async def client_handler(websocket, path):
# Create WebSocket listener
start_server = websockets.serve(client_handler, '0.0.0.0', 32715)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
try:
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
except KeyboardInterrupt:
print("[received SIGINT]")
pass
finally:
print("Exiting...")