Skip to content

Commit 254bfe7

Browse files
committed
Fix: prevent keepalive task leak on reconnection in KeepAliveWebSocket
1 parent d549914 commit 254bfe7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

binance/ws/keepalive_websocket.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ async def _before_connect(self):
6262
self._build_path()
6363

6464
async def _after_connect(self):
65-
self._start_socket_timer()
65+
if self._timer is None:
66+
self._start_socket_timer()
6667

6768
def _start_socket_timer(self):
6869
self._timer = self._loop.call_later(
@@ -141,4 +142,7 @@ async def _keepalive_socket(self):
141142
except Exception as e:
142143
self._log.error(f"error in keepalive_socket: {e}")
143144
finally:
144-
self._start_socket_timer()
145+
if self._timer is not None:
146+
self._start_socket_timer()
147+
else:
148+
self._log.info('skip timer restart - web socket is exit')

0 commit comments

Comments
 (0)