unicex 0.13.3__py3-none-any.whl → 0.13.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unicex/_base/websocket.py +22 -20
- {unicex-0.13.3.dist-info → unicex-0.13.4.dist-info}/METADATA +1 -1
- {unicex-0.13.3.dist-info → unicex-0.13.4.dist-info}/RECORD +6 -6
- {unicex-0.13.3.dist-info → unicex-0.13.4.dist-info}/WHEEL +0 -0
- {unicex-0.13.3.dist-info → unicex-0.13.4.dist-info}/licenses/LICENSE +0 -0
- {unicex-0.13.3.dist-info → unicex-0.13.4.dist-info}/top_level.txt +0 -0
unicex/_base/websocket.py
CHANGED
|
@@ -17,7 +17,7 @@ from unicex.types import LoggerLike
|
|
|
17
17
|
class Websocket:
|
|
18
18
|
"""Базовый класс асинхронного вебсокета."""
|
|
19
19
|
|
|
20
|
-
MAX_QUEUE_SIZE: int =
|
|
20
|
+
MAX_QUEUE_SIZE: int = 500
|
|
21
21
|
"""Максимальная длина очереди."""
|
|
22
22
|
|
|
23
23
|
class _DecoderProtocol(Protocol):
|
|
@@ -111,25 +111,27 @@ class Websocket:
|
|
|
111
111
|
async def _connect(self) -> None:
|
|
112
112
|
"""Подключается к вебсокету и настраивает соединение."""
|
|
113
113
|
self._logger.debug(f"Establishing connection with {self._url}")
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
114
|
+
async for conn in websockets.connect(uri=self._url, **self._generate_ws_kwargs()):
|
|
115
|
+
try:
|
|
116
|
+
self._logger.info(f"Websocket connection was established to {self._url}")
|
|
117
|
+
await self._after_connect(conn)
|
|
118
|
+
|
|
119
|
+
# Цикл получения сообщений
|
|
120
|
+
while self._running:
|
|
121
|
+
message = await conn.recv()
|
|
122
|
+
await self._handle_message(message)
|
|
123
|
+
|
|
124
|
+
except websockets.exceptions.ConnectionClosed as e:
|
|
125
|
+
self._logger.error(f"Websocket connection was closed unexpectedly: {e}")
|
|
126
|
+
except Exception as e:
|
|
127
|
+
self._logger.error(f"Unexpected error in websosocket connection: {e}")
|
|
128
|
+
finally:
|
|
129
|
+
# Делаем реконнект только если вебсокет активен, иначе выходим из итератора
|
|
130
|
+
if self._running:
|
|
131
|
+
await asyncio.sleep(self._reconnect_timeout)
|
|
132
|
+
await self._after_disconnect()
|
|
133
|
+
else:
|
|
134
|
+
return # Выходим из итератора, если вебсокет уже выключен
|
|
133
135
|
|
|
134
136
|
async def _handle_message(self, message: str | bytes) -> None:
|
|
135
137
|
"""Обрабатывает входящее сообщение вебсокета."""
|
|
@@ -11,7 +11,7 @@ unicex/_abc/uni_client.py,sha256=ZjxK8aqCGLUUYy1UQTM9EvWn1IXwMkH2Db8sZrs1e_I,137
|
|
|
11
11
|
unicex/_abc/uni_websocket_manager.py,sha256=yYKypPkIe3rKfWBuTsS8rkwIPljpd1588CYDkeTOYqE,9905
|
|
12
12
|
unicex/_base/__init__.py,sha256=0TmevATGnRB3qow6tkCR8dQKNZCWKeib6YQjNJ4a1b0,236
|
|
13
13
|
unicex/_base/client.py,sha256=asIIQLZlRwwmUDvxveSv7aCvth54iiSRJdz19bxGorI,8904
|
|
14
|
-
unicex/_base/websocket.py,sha256=
|
|
14
|
+
unicex/_base/websocket.py,sha256=QMUXpQemmL5I-mE2j6i5SUL_pu8ZxUcQWduSSZ8nppE,11768
|
|
15
15
|
unicex/binance/__init__.py,sha256=sDk4ZjakRdpFMaMSpOCfqjf6ZPfAS9tlrt4WlDHtDkw,932
|
|
16
16
|
unicex/binance/adapter.py,sha256=JbUFyjnDAFtyuYYrh90YeOvQOZQ6faim0nWS6U0NxXw,8799
|
|
17
17
|
unicex/binance/client.py,sha256=1qPx0uRT4prC6saLBQ55pXDWcWTCKhYEwVIysiihPgU,60984
|
|
@@ -86,8 +86,8 @@ unicex/okx/uni_client.py,sha256=E_Wod0JSGt1K6k1mAIWnOv350pELbv-nic7g1KgOuos,8694
|
|
|
86
86
|
unicex/okx/uni_websocket_manager.py,sha256=b4f_QjA64DJmENQdIGb5IOVc7kvit7KMCdWeCmRbxGY,9326
|
|
87
87
|
unicex/okx/user_websocket.py,sha256=8c9kpm-xVa729pW93OKUGLHaE9MY0uzEpjIgNIFRF80,126
|
|
88
88
|
unicex/okx/websocket_manager.py,sha256=wROXTUDqKzOE-wDnCtXso_MC4SzfPuPols5aPg_Z3y4,26027
|
|
89
|
-
unicex-0.13.
|
|
90
|
-
unicex-0.13.
|
|
91
|
-
unicex-0.13.
|
|
92
|
-
unicex-0.13.
|
|
93
|
-
unicex-0.13.
|
|
89
|
+
unicex-0.13.4.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
|
|
90
|
+
unicex-0.13.4.dist-info/METADATA,sha256=JJ9HinBsvn_N73vdORc00UshzpIHa0HWojl3ooMjO14,11752
|
|
91
|
+
unicex-0.13.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
92
|
+
unicex-0.13.4.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
|
|
93
|
+
unicex-0.13.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|