Skip to content

fix double scheduling#329

Open
waldner wants to merge 1 commit into
rq:masterfrom
waldner:master
Open

fix double scheduling#329
waldner wants to merge 1 commit into
rq:masterfrom
waldner:master

Conversation

@waldner

@waldner waldner commented May 28, 2026

Copy link
Copy Markdown

Should fix #260.

Summary by CodeRabbit

  • Bug Fixes
    • Improved timezone handling in scheduled job execution to ensure accurate calculation of next execution times based on selected timezone settings.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b853788-d51c-4238-9a6f-555199064c2f

📥 Commits

Reviewing files that changed from the base of the PR and between 134c2eb and 02cab87.

📒 Files selected for processing (1)
  • rq_scheduler/utils.py

📝 Walkthrough

Walkthrough

This PR fixes double execution of scheduled jobs when use_local_timezone=True. The get_next_scheduled_time function now computes a timezone-aware now value with the correct timezone before passing it to cron.next(), and removes the redundant post-conversion that was causing incorrect scheduling.

Changes

Timezone-aware cron scheduling fix

Layer / File(s) Summary
Fix timezone handling in get_next_scheduled_time
rq_scheduler/utils.py
get_next_scheduled_time creates a timezone-aware now using datetime.now(tz) and passes it to cron.next(...) directly, removing the redundant astimezone(tz) post-conversion that caused double execution when use_local_timezone=True.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through timezones with care,
No more double-scheduling nightmares!
Local and UTC in harmony dwell,
With datetime.now(tz) casting its spell—
One hop, one job, one moment so fair! 🌍⏰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix double scheduling' directly addresses the main objective of preventing duplicate job executions when using use_local_timezone=True.
Linked Issues check ✅ Passed The code changes modify timezone handling in get_next_scheduled_time to compute current time with the selected timezone and pass it to cron.next(), eliminating the post-conversion step that likely caused double scheduling.
Out of Scope Changes check ✅ Passed Changes are confined to timezone handling logic in rq_scheduler/utils.py and directly address the linked issue #260 about duplicate executions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

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.

Jobs scheduled with use_local_timezone=True are executed twice

1 participant