fix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user