use async await to close websocket server

This commit is contained in:
Fabian Dill 2020-03-07 17:24:51 +01:00
parent b7814ca050
commit 1d84b126f6
1 changed files with 5 additions and 4 deletions

View File

@ -484,8 +484,9 @@ def set_password(ctx : Context, password):
logging.warning('Password set to ' + password if password else 'Password disabled') logging.warning('Password set to ' + password if password else 'Password disabled')
async def console(ctx : Context): async def console(ctx: Context):
while True: running = True
while running:
input = await aioconsole.ainput() input = await aioconsole.ainput()
try: try:
@ -494,8 +495,8 @@ async def console(ctx : Context):
continue continue
if command[0] == '/exit': if command[0] == '/exit':
ctx.server.ws_server.close() await ctx.server.ws_server._close()
break running = False
if command[0] == '/players': if command[0] == '/players':
logging.info(get_connected_players_string(ctx)) logging.info(get_connected_players_string(ctx))