Ignore `LocalProtocolError` on `binance` quote feeds
Closed this issue · 0 comments
goodboy commented
Tried to handle it in #431 but turns out the randomly triggered traceback looks like:
raceback (most recent call last):
File "/home/goodboy/repos/tractor/tractor/_runtime.py", line 196, in _invoke
res = await coro
File "/home/goodboy/repos/piker/piker/data/feed.py", line 244, in _setup_persistent_brokerd
async with trio.open_nursery() as service_nursery:
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio/_core/_run.py", line 850, in __aexit__
raise combined_error_from_nursery
File "/home/goodboy/repos/piker/piker/brokers/binance.py", line 551, in stream_quotes
async for typ, msg in msg_gen:
File "/home/goodboy/repos/piker/piker/brokers/binance.py", line 325, in stream_messages
await ws._connect()
File "/home/goodboy/repos/piker/piker/data/_web_bs.py", line 76, in _connect
await self._stack.aclose()
File "/usr/lib/python3.10/contextlib.py", line 656, in aclose
await self.__aexit__(None, None, None)
File "/usr/lib/python3.10/contextlib.py", line 714, in __aexit__
raise exc_details[1]
File "/usr/lib/python3.10/contextlib.py", line 697, in __aexit__
cb_suppress = await cb(*exc_details)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/async_generator/_util.py", line 42, in __aexit__
await self._agen.asend(None)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/async_generator/_impl.py", line 366, in step
return await ANextIter(self._it, start_fn, *args)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/async_generator/_impl.py", line 202, in send
return self._invoke(self._it.send, value)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/async_generator/_impl.py", line 209, in _invoke
result = fn(*args)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio_websocket/_impl.py", line 105, in open_websocket
async with trio.open_nursery() as new_nursery:
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio/_core/_run.py", line 850, in __aexit__
raise combined_error_from_nursery
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio_websocket/_impl.py", line 1205, in _reader_task
await handler(event)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio_websocket/_impl.py", line 1145, in _handle_ping_event
await self._send(event.response())
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/trio_websocket/_impl.py", line 1249, in _send
data = self._wsproto.send(event)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/wsproto/__init__.py", line 64, in send
data += self.connection.send(event)
File "/home/goodboy/.virtualenvs/piker310/lib/python3.10/site-packages/wsproto/connection.py", line 107, in send
raise LocalProtocolError(
wsproto.utilities.LocalProtocolError: Event Pong(payload=bytearray(b'1671414055763')) cannot be sent in state ConnectionState.LOCAL_CLOSING.
which means we might have to override internals of the trio_websocket
code...