Skip to content

Commit

Permalink
Fix scheduler to correct set next_run_time based on UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrss committed Jun 9, 2024
1 parent 120a91d commit b51e74e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion botto/mixins/reaction_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion botto/mixins/remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions botto/reminder_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion botto/tld_botto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b51e74e

Please sign in to comment.