refactor(autorenewal): clean up imports and simplify error handling
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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__":
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -227,4 +227,4 @@ AUTORENEWAL_INSUFFICIENT_FUNDS = (
|
||||
AUTORENEWAL_SUCCESS = (
|
||||
"<b>✅ Подписка продлена автоматически. Списано <code>{price}₽</code>.</b>"
|
||||
"Новая дата окончания: <code>{end_date}</code>."
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user