This commit is contained in:
kandrusyak
2026-07-25 15:39:03 +03:00
parent 0163208484
commit 3f63d0305c
6 changed files with 148 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
import asyncio
import logging
from contextlib import suppress
from zoneinfo import ZoneInfo
from telegram.ext import Application
@@ -38,5 +39,17 @@ async def reminder_loop(application: Application) -> None:
async def post_init(application: Application) -> None:
application.create_task(reminder_loop(application))
application.bot_data["reminder_task"] = asyncio.create_task(
reminder_loop(application),
name="reminder-loop",
)
async def post_shutdown(application: Application) -> None:
task = application.bot_data.pop("reminder_task", None)
if task is None:
return
task.cancel()
with suppress(asyncio.CancelledError):
await task