Skip to content
Snippets Groups Projects
Commit 107ab665 authored by Tulir Asokan's avatar Tulir Asokan
Browse files

Fix Python 3.10 compatibility

parent 2b7e732c
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ class ReminderBot(Plugin): ...@@ -45,7 +45,7 @@ class ReminderBot(Plugin):
async def start(self) -> None: async def start(self) -> None:
self.on_external_config_update() self.on_external_config_update()
self.db = ReminderDatabase(self.database) self.db = ReminderDatabase(self.database)
self.reminder_loop_task = asyncio.ensure_future(self.reminder_loop(), loop=self.loop) self.reminder_loop_task = asyncio.create_task(self.reminder_loop())
def on_external_config_update(self) -> None: def on_external_config_update(self) -> None:
self.config.load_and_update() self.config.load_and_update()
...@@ -78,7 +78,7 @@ class ReminderBot(Plugin): ...@@ -78,7 +78,7 @@ class ReminderBot(Plugin):
async def schedule_nearby_reminders(self, now: datetime) -> None: async def schedule_nearby_reminders(self, now: datetime) -> None:
until = now + timedelta(minutes=1) until = now + timedelta(minutes=1)
for reminder in self.db.all_in_range(now, until): for reminder in self.db.all_in_range(now, until):
asyncio.ensure_future(self.send_reminder(reminder), loop=self.loop) asyncio.create_task(self.send_reminder(reminder))
async def send_reminder(self, reminder: ReminderInfo) -> None: async def send_reminder(self, reminder: ReminderInfo) -> None:
try: try:
...@@ -175,7 +175,7 @@ class ReminderBot(Plugin): ...@@ -175,7 +175,7 @@ class ReminderBot(Plugin):
now = datetime.now(tz=pytz.UTC) now = datetime.now(tz=pytz.UTC)
if (rem.date - now).total_seconds() < 60 and now.minute == rem.date.minute: if (rem.date - now).total_seconds() < 60 and now.minute == rem.date.minute:
self.log.debug(f"Reminder {rem} is in less than a minute, scheduling now...") self.log.debug(f"Reminder {rem} is in less than a minute, scheduling now...")
asyncio.ensure_future(self.send_reminder(rem), loop=self.loop) asyncio.create_task(self.send_reminder(rem))
@remind.subcommand("help", help="Usage instructions") @remind.subcommand("help", help="Usage instructions")
async def help(self, evt: MessageEvent) -> None: async def help(self, evt: MessageEvent) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment