Update file file_service.py
This commit is contained in:
@@ -307,6 +307,10 @@ class FileService:
|
|||||||
return f"[Ошибка распознавания: {e}]"
|
return f"[Ошибка распознавания: {e}]"
|
||||||
|
|
||||||
async def _get_salute_token(self) -> Optional[str]:
|
async def _get_salute_token(self) -> Optional[str]:
|
||||||
|
"""
|
||||||
|
Асинхронно получает токен доступа к SaluteSpeech по Basic авторизации.
|
||||||
|
Блокирующий вызов requests.post обёрнут в asyncio.to_thread.
|
||||||
|
"""
|
||||||
import uuid
|
import uuid
|
||||||
salute_auth = self.config.salute_speech_auth
|
salute_auth = self.config.salute_speech_auth
|
||||||
if not salute_auth:
|
if not salute_auth:
|
||||||
@@ -322,6 +326,7 @@ class FileService:
|
|||||||
try:
|
try:
|
||||||
def _sync_request():
|
def _sync_request():
|
||||||
return requests.post(url, headers=headers, data=payload, verify=False)
|
return requests.post(url, headers=headers, data=payload, verify=False)
|
||||||
|
# ОБЁРТКА: синхронный запрос выполняется в отдельном потоке
|
||||||
response = await asyncio.to_thread(_sync_request)
|
response = await asyncio.to_thread(_sync_request)
|
||||||
token = response.json().get('access_token')
|
token = response.json().get('access_token')
|
||||||
logger.info("SaluteSpeech token получен")
|
logger.info("SaluteSpeech token получен")
|
||||||
|
|||||||
Reference in New Issue
Block a user