From 1d84b126f6d14788ab88da2f100a6e5b3013cf7e Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 7 Mar 2020 17:24:51 +0100 Subject: [PATCH] use async await to close websocket server --- MultiServer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index 1a9ec991..8d7ab14e 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -484,8 +484,9 @@ def set_password(ctx : Context, password): logging.warning('Password set to ' + password if password else 'Password disabled') -async def console(ctx : Context): - while True: +async def console(ctx: Context): + running = True + while running: input = await aioconsole.ainput() try: @@ -494,8 +495,8 @@ async def console(ctx : Context): continue if command[0] == '/exit': - ctx.server.ws_server.close() - break + await ctx.server.ws_server._close() + running = False if command[0] == '/players': logging.info(get_connected_players_string(ctx))