Skip to content

Commit

Permalink
Handle imports from websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
sammchardy committed Mar 29, 2022
1 parent 2868498 commit 4251caf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions binance/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
self._is_binary = is_binary
self._conn = None
self._socket = None
self.ws: Optional[ws.WebSocketClientProtocol] = None
self.ws: Optional[ws.WebSocketClientProtocol] = None # type: ignore
self.ws_state = WSListenerState.INITIALISING
self._queue = asyncio.Queue()
self._handle_read_loop = None
Expand All @@ -84,7 +84,7 @@ async def connect(self):
assert self._path
self.ws_state = WSListenerState.STREAMING
ws_url = self._url + self._prefix + self._path
self._conn = ws.connect(ws_url, close_timeout=0.1)
self._conn = ws.connect(ws_url, close_timeout=0.1) # type: ignore
try:
self.ws = await self._conn.__aenter__()
except: # noqa
Expand Down Expand Up @@ -131,10 +131,10 @@ async def _read_loop(self):
break
elif self.ws_state == WSListenerState.EXITING:
break
elif self.ws.state == ws.protocol.State.CLOSING:
elif self.ws.state == ws.protocol.State.CLOSING: # type: ignore
await asyncio.sleep(0.1)
continue
elif self.ws.state == ws.protocol.State.CLOSED:
elif self.ws.state == ws.protocol.State.CLOSED: # type: ignore
await self._reconnect()
elif self.ws_state == WSListenerState.STREAMING:
res = await asyncio.wait_for(self.ws.recv(), timeout=self.TIMEOUT)
Expand Down

0 comments on commit 4251caf

Please sign in to comment.