From 6f8bc0e7622633fac6bff3e0424c49c9654769a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Sep 2025 00:40:08 +0300 Subject: [PATCH] patch chat --- app/core/http_client.py | 17 +++++++++++++++++ app/core/services/chat_service.py | 3 ++- main.py | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/core/http_client.py diff --git a/app/core/http_client.py b/app/core/http_client.py new file mode 100644 index 0000000..3ebd3ab --- /dev/null +++ b/app/core/http_client.py @@ -0,0 +1,17 @@ +import ssl +import httpx + +ssl_transport = httpx.AsyncHTTPTransport(http2=True) + +# Ограничения пула соединений +limits = httpx.Limits(max_connections=200, max_keepalive_connections=50) + +# Таймауты +timeout = httpx.Timeout(connect=5.0, read=10.0, write=5.0, pool=5.0) + +# Глобальный клиент +client = httpx.AsyncClient( + transport=ssl_transport, + limits=limits, + timeout=timeout, +) diff --git a/app/core/services/chat_service.py b/app/core/services/chat_service.py index 913d3b4..8943426 100644 --- a/app/core/services/chat_service.py +++ b/app/core/services/chat_service.py @@ -32,7 +32,8 @@ async def get_private_chats(token: str, offset: int = 0, limit: int = 20): if data.get("status") == "fine": # Используем Pydantic модель для парсинга ответа response_model = PrivateChatListResponse(**data) - print("response_model.data", response_model.data) + # print("response_model.data", response_model.data) + print("data", data) return True, response_model.data else: return False, data.get("detail", localizer.translate("Неизвестная ошибка ответа")) diff --git a/main.py b/main.py index 05a9448..cbc9afe 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ class MainWindow(QMainWindow): super().__init__() self.setWindowTitle(config.APP_HEADER) self.setMinimumSize(400, 650) - + self.controller = MainController() self.setCentralWidget(self.controller)