From 1cbc4541a8bbccc1b139e39b8eaac68514270d98 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 5 Apr 2020 01:27:29 -0300 Subject: [PATCH] Handle connection closed when sending RECONNECT --- litecord/gateway/state_manager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/litecord/gateway/state_manager.py b/litecord/gateway/state_manager.py index eb2e0fb..9239159 100644 --- a/litecord/gateway/state_manager.py +++ b/litecord/gateway/state_manager.py @@ -190,14 +190,14 @@ class StateManager: """Send OP Reconnect to a single connection.""" websocket = state.ws - await websocket.send({"op": OP.RECONNECT}) - - # wait 200ms - # so that the client has time to process - # our payload then close the connection - await asyncio.sleep(0.2) - try: + await websocket.send({"op": OP.RECONNECT}) + + # wait 200ms + # so that the client has time to process + # our payload then close the connection + await asyncio.sleep(0.2) + # try to close the connection ourselves await websocket.ws.close(code=4000, reason="litecord shutting down") except ConnectionClosed: