Skip to content

Commit 658f1fb

Browse files
authored
fix: close read loop before closing websocket fix #1530 (#1535)
1 parent ad6f6ea commit 658f1fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

binance/ws/reconnecting_websocket.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,15 @@ async def close(self):
9595

9696
async def __aexit__(self, exc_type, exc_val, exc_tb):
9797
self._log.debug(f"Closing Websocket {self._url}{self._prefix}{self._path}")
98+
if self._handle_read_loop:
99+
await self._kill_read_loop()
98100
if self._exit_coro:
99101
await self._exit_coro(self._path)
100-
self.ws_state = WSListenerState.EXITING
101102
if self.ws:
102103
await self.ws.close()
103104
if self._conn and hasattr(self._conn, "protocol"):
104105
await self._conn.__aexit__(exc_type, exc_val, exc_tb)
105106
self.ws = None
106-
if self._handle_read_loop:
107-
await self._kill_read_loop()
108107

109108
async def connect(self):
110109
self._log.debug("Establishing new WebSocket connection")

0 commit comments

Comments
 (0)