Skip to content

fix: add default_utc=True to cron.next()#324

Open
nicolapace wants to merge 1 commit intorq:masterfrom
nicolapace:patch-2
Open

fix: add default_utc=True to cron.next()#324
nicolapace wants to merge 1 commit intorq:masterfrom
nicolapace:patch-2

Conversation

@nicolapace
Copy link

Fix crontab FutureWarning for UTC behavior change

Update crontab usage to explicitly specify UTC behavior to resolve deprecation warnings and ensure consistent timezone handling.

What changed:

Added default_utc=True parameter to cron.next() calls in rq_scheduler usage
This explicitly opts into the new UTC-aware behavior that will become default in crontab 0.22.0+

Why:

crontab library is changing default behavior from local time to UTC in version 0.22.0+
Current usage generates FutureWarning about this breaking change
Explicitly specifying default_utc=True ensures consistent UTC behavior across versions
Aligns with best practices for scheduler operations which should use UTC

Testing:

Verified scheduled jobs continue to execute at correct times
Confirmed no regression in cron scheduling functionality
UTC timing behavior remains consistent

Note:

This change explicitly adopts the new UTC-first behavior that crontab will make default, ensuring our scheduler operations remain predictable across library updates.

@adamantike
Copy link

Aligns with best practices for scheduler operations which should use UTC

I would assume end users would expect their Cron expressions to be evaluated against the system's timezone instead. Considering that, would default_utc=False be a better fit, while also removing crontab's warning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants