Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions binance/ws/websocket_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Dict, Optional
from typing import TYPE_CHECKING, Dict, Optional
import asyncio

from websockets import WebSocketClientProtocol # type: ignore
if TYPE_CHECKING:
from websockets import WebSocketClientProtocol # type: ignore # noqa: F401

from .constants import WSListenerState
from .reconnecting_websocket import ReconnectingWebsocket
Expand Down Expand Up @@ -117,7 +118,7 @@ async def _ensure_ws_connection(self) -> None:
try:
if (
self.ws is None
or (isinstance(self.ws, WebSocketClientProtocol) and self.ws.closed)
or (hasattr(self.ws, "closed") and self.ws.closed)
or self.ws_state != WSListenerState.STREAMING
):
await self.connect()
Expand Down