fix(bot): retry admin video upload on transient httpx transport errors
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 1m44s

send_video_to_admin_bot() had no retry, unlike the client-facing
reply_video() path fixed earlier — a transient httpx.ReadError during
upload silently dropped the admin copy while the user still got their
video, since this function swallows its own exceptions.
This commit is contained in:
vrubelroman 2026-06-30 20:31:37 +00:00
parent 67dba21ff9
commit ac2bd8f644

15
bot.py
View file

@ -488,8 +488,11 @@ async def send_video_to_admin_bot(video_path: str, url: str, from_user=None):
if user_info: if user_info:
caption += f"\n👤 {user_info}" caption += f"\n👤 {user_info}"
# Отправляем видео # Отправляем видео (с ретраем — транспортные ошибки httpx при аплоаде бывают и здесь)
with open(video_path, 'rb') as video_file: send_retries = 3
for attempt in range(send_retries):
video_file = open(video_path, 'rb')
try:
await admin_bot.send_video( await admin_bot.send_video(
chat_id=admin_chat_id, chat_id=admin_chat_id,
video=video_file, video=video_file,
@ -500,6 +503,14 @@ async def send_video_to_admin_bot(video_path: str, url: str, from_user=None):
connect_timeout=60, connect_timeout=60,
pool_timeout=60 pool_timeout=60
) )
break
except Exception as send_error:
if attempt == send_retries - 1:
raise
logger.warning(f"Отправка видео админ боту: попытка {attempt + 1}/{send_retries} не удалась: {send_error}")
await asyncio.sleep((attempt + 1) * 2)
finally:
video_file.close()
logger.info(f"Видео отправлено админ боту: {video_path}") logger.info(f"Видео отправлено админ боту: {video_path}")