In init.py of websocket, it would be better like this (commented the original incorrect line):
try:
# cmsg: Union[
# List[WebSocketMessage], Union[str, bytes]
# ] = await s.recv()
cmsg: Union[
List[WebSocketMessage], Union[str, bytes]
] = await asyncio.wait_for(s.recv(), timeout=1)
except asyncio.TimeoutError:
continue
Imagine a case where someone is subscribed to trades on an illiquid instrument. So maybe it takes 5-10 minutes before a trade message received. If they try to change the active subscriptions, no error is raised, but silently, no actual change in subscription has ocurred until there's a trade on that illiquid instrument.