diff --git a/pybit/_websocket_stream.py b/pybit/_websocket_stream.py index 2ba0086..b006b7c 100644 --- a/pybit/_websocket_stream.py +++ b/pybit/_websocket_stream.py @@ -266,6 +266,7 @@ def _send_initial_ping(self): timer = threading.Timer( self.ping_interval, self._send_custom_ping ) + self.ping_timer = timer timer.start() @staticmethod @@ -288,7 +289,8 @@ def exit(self): """ Closes the websocket connection. """ - + if self.ping_timer: + self.ping_timer.cancel() self.ws.close() while self.ws.sock: continue