Add some backup checks when stopping maubot

This commit is contained in:
Tulir Asokan 2018-11-11 21:20:50 +02:00
parent 20a9ca6aa6
commit 6f2162d5f3
3 changed files with 10 additions and 3 deletions

View file

@ -90,7 +90,10 @@ except KeyboardInterrupt:
log.debug("Closing websockets")
loop.run_until_complete(stop_management_api())
log.debug("Stopping server")
loop.run_until_complete(server.stop())
try:
loop.run_until_complete(asyncio.wait_for(server.stop(), 5, loop=loop))
except asyncio.TimeoutError:
log.warning("Stopping server timed out")
log.debug("Closing event loop")
loop.close()
log.debug("Everything stopped, shutting down")