Skip to content

Commit 90fc49a

Browse files
author
Sam McHardy
committed
Handle websocket disconnecting
1 parent 1a1c0b4 commit 90fc49a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

binance/depthcache.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ def _depth_event(self, msg):
199199
200200
"""
201201

202+
if 'e' in msg and msg['e'] == 'error':
203+
# close the socket
204+
self.close()
205+
206+
# notify the user by returning a None value
207+
if self._callback:
208+
self._callback(None)
209+
202210
if self._last_update_id is None:
203211
# Initial depth snapshot fetch not yet performed, buffer messages
204212
self._depth_message_buffer.append(msg)
@@ -251,3 +259,4 @@ def close(self):
251259
:return:
252260
"""
253261
self._bm.close()
262+
self._depth_cache = None

0 commit comments

Comments
 (0)