From b51e74ee6244b2f4c07e05984579957372f58cca Mon Sep 17 00:00:00 2001 From: David Stephens Date: Sat, 8 Jun 2024 21:35:56 +0100 Subject: [PATCH] Fix scheduler to correct set next_run_time based on UTC --- botto/mixins/reaction_roles.py | 2 +- botto/mixins/remote_config.py | 2 +- botto/reminder_manager.py | 8 ++++---- botto/tld_botto.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/botto/mixins/reaction_roles.py b/botto/mixins/reaction_roles.py index d7b08f8..7e87de0 100644 --- a/botto/mixins/reaction_roles.py +++ b/botto/mixins/reaction_roles.py @@ -80,7 +80,7 @@ def __init__( trigger="cron", minute="*/30", coalesce=True, - next_run_time=datetime.now() + timedelta(seconds=5), + next_run_time=datetime.utcnow() + timedelta(seconds=5), misfire_grace_time=10, ) self.tester_locks = WeakValueDictionary() diff --git a/botto/mixins/remote_config.py b/botto/mixins/remote_config.py index 64d7725..0fb4486 100644 --- a/botto/mixins/remote_config.py +++ b/botto/mixins/remote_config.py @@ -25,7 +25,7 @@ def __init__( trigger="cron", minute="*/40", coalesce=True, - next_run_time=datetime.now() + timedelta(seconds=5), + next_run_time=datetime.utcnow() + timedelta(seconds=5), ) super().__init__(scheduler=scheduler, **kwargs) diff --git a/botto/reminder_manager.py b/botto/reminder_manager.py index d6c9e18..a3c503e 100644 --- a/botto/reminder_manager.py +++ b/botto/reminder_manager.py @@ -35,7 +35,7 @@ def __init__( self.missed_job_ids = [] self.get_channel_func = None - initial_refresh_run = datetime.now() + timedelta(seconds=5) + initial_refresh_run = datetime.utcnow() + timedelta(seconds=5) scheduler.add_job( self.refresh_reminders, name="Refresh reminders", @@ -264,9 +264,9 @@ async def list_reminders( ) -> list[Reminder]: reminders_for_guild: list[Reminder] = [] async for reminder in self.storage.retrieve_reminders(): - reminder_channel: Optional[ - discord.TextChannel - ] = await self.get_channel_func(reminder.channel_id) + reminder_channel: Optional[discord.TextChannel] = ( + await self.get_channel_func(reminder.channel_id) + ) if not reminder_channel or reminder_channel.guild.id != guild.id: continue if channel is not None and reminder_channel.id != channel.id: diff --git a/botto/tld_botto.py b/botto/tld_botto.py index 83e2713..e7383f7 100644 --- a/botto/tld_botto.py +++ b/botto/tld_botto.py @@ -142,7 +142,7 @@ def __init__( hour="*/12", coalesce=True, ) - initial_refresh_run = datetime.now() + timedelta(seconds=5) + initial_refresh_run = datetime.utcnow() + timedelta(seconds=5) scheduler.add_job( self.storage.update_meals_cache, name="Refresh meals cache",