refactor(autorenewal): clean up imports and simplify error handling

This commit is contained in:
2026-05-18 17:58:34 +07:00
parent a9a650f37b
commit 1228ec8b56
9 changed files with 19 additions and 34 deletions

View File

@@ -10,9 +10,7 @@ from bot.texts import (
CALLBACK_FALLBACK,
FAQ_TEXT,
GENERAL_PROCESSING,
GENERAL_SUCCESS,
NO_SUBSCRIPTION,
NOTHING_PLACEHOLDER,
)
from db.models.users import User
from misc import utils

View File

@@ -1,4 +1,5 @@
import asyncio
import contextlib
import logging
from aiogram import Bot, Dispatcher
@@ -21,6 +22,7 @@ from services.renewal_service import RenewalService
from services.user_service import UserService
logging.basicConfig(level=logging.DEBUG)
contextlib.suppress(asyncio.CancelledError)
async def main():
@@ -78,10 +80,7 @@ async def main():
await dp.start_polling(bot)
finally:
scheduler_task.cancel()
try:
await scheduler_task
except asyncio.CancelledError:
pass
await scheduler_task
if __name__ == "__main__":

View File

@@ -1,7 +1,7 @@
import asyncio
import logging
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
from sqlalchemy.ext.asyncio import async_sessionmaker
from services.renewal_service import RenewalService

View File

@@ -227,4 +227,4 @@ AUTORENEWAL_INSUFFICIENT_FUNDS = (
AUTORENEWAL_SUCCESS = (
"<b>✅ Подписка продлена автоматически. Списано <code>{price}₽</code>.</b>"
"Новая дата окончания: <code>{end_date}</code>."
)
)