Skip to content

feat(python): manage the periodic-schedule catalog - #502

Merged
pratyush618 merged 8 commits into
masterfrom
feat/python-periodic-catalog
Jul 23, 2026
Merged

feat(python): manage the periodic-schedule catalog#502
pratyush618 merged 8 commits into
masterfrom
feat/python-periodic-catalog

Conversation

@kartikeya-27

@kartikeya-27 kartikeya-27 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #501.

Python could declare a cron schedule with @queue.periodic() but never manage one afterwards — no way to list, unschedule, pause, or resume. The native module already had all four; only the Python wrappers were missing.

queue.list_periodic()  # every registered schedule, enabled or paused

queue.pause_periodic("daily-digest")  # stop firing, keep the registration
queue.resume_periodic("daily-digest")
queue.delete_periodic("daily-digest")  # unschedule; False if unknown

Each entry is a PeriodicInfoname, task_name, cron_expr, queue, enabled, last_run, next_run, timezone. Every method has an a-prefixed async form.

Notable choices

Widened the binding's return. PyQueue.list_periodic yielded (name, task_name, cron_expr, enabled) tuples, dropping queue, last_run, next_run and timezone — a caller could not tell when a schedule next fires. It now emits dicts covering the whole row (the dead_letters pattern), decoded into a frozen PeriodicInfo. No Python caller consumed the tuple form, so nothing breaks.

Dedicated mixins/periodic.py rather than splitting reads into inspection.py and writes into operations.py, mirroring mixins/pubsub.py, which co-locates its TopicMessage view with the mixin owning that concern.

Catalog vs. declaration. @queue.periodic() only declares a schedule; run_worker() is what writes it to storage. These methods act on storage, so a schedule outlives the decorator that created it — the docs now state that a producer-only process sees an empty list, and that retiring a schedule means delete_periodic(), not deleting the decorator. That last warning already existed; it now has a remedy attached.

Docs

The "Managing periodic tasks" section of the scheduling guide carried a Python block saying no such API existed. Replaced with real usage matching the sibling blocks, plus a periodic-catalog table in the Python queue API reference.

Verification

  • cargo clippy -p taskito-python --all-targets — clean
  • uv run python -m pytest tests/1292 passed, 7 skipped; 5 new tests cover field population, pause/resume, delete, unknown names, and the async wrappers
  • ruff check (source + tests) · ruff format --check · mypy taskito/ — clean
  • pnpm --dir docs build — clean

Out of scope

PyQueue.register_periodic still hardcodes enabled: true, so Python cannot register a schedule pre-paused the way the other shells can. Separate gap, left alone.

Summary by CodeRabbit

  • New Features
    • Added Python APIs to list, pause, resume, and delete registered periodic schedules.
    • list_periodic() now returns periodic entries with full schedule metadata (name, task, cron, queue, enabled state, last/next run, and timezone).
    • Added asynchronous equivalents for all periodic schedule management operations.
    • Exported the PeriodicInfo type for public use.
  • Documentation
    • Documented the periodic schedule catalog behavior, returned fields, and timestamp semantics.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

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: f91ca506-81ab-4deb-829e-b7738dfb5a42

📥 Commits

Reviewing files that changed from the base of the PR and between a44f49d and dee1bc8.

📒 Files selected for processing (3)
  • docs/content/docs/shared/guides/core/scheduling.mdx
  • sdks/python/taskito/mixins/periodic.py
  • sdks/python/tests/core/test_periodic.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • sdks/python/taskito/mixins/periodic.py
  • docs/content/docs/shared/guides/core/scheduling.mdx
  • sdks/python/tests/core/test_periodic.py

📝 Walkthrough

Walkthrough

Python periodic schedules now expose catalog listing, pause/resume/delete operations, complete schedule metadata, asynchronous wrappers, package exports, documentation, and tests.

Changes

Periodic catalog management

Layer / File(s) Summary
Periodic catalog data contract
crates/taskito-python/src/py_queue/mod.rs, sdks/python/taskito/_taskito.pyi, sdks/python/taskito/mixins/periodic.py, sdks/python/taskito/__init__.py
Periodic listings now return dictionaries decoded into exported PeriodicInfo records containing schedule identity, timing, queue, enabled state, and timezone metadata.
Queue API and async delegation
sdks/python/taskito/app.py, sdks/python/taskito/mixins/*, sdks/python/taskito/async_support/mixins.py
Queue gains synchronous periodic catalog operations, while asynchronous variants delegate through _run_sync; the periodic mixin is publicly exported.
Catalog validation and documentation
sdks/python/tests/core/test_periodic.py, docs/content/docs/python/api-reference/queue/index.mdx, docs/content/docs/shared/guides/core/scheduling.mdx
Tests cover metadata and lifecycle behavior, and documentation describes synchronous/asynchronous APIs and persistent schedule semantics.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • ByteVeda/taskito#313: Implements related periodic catalog CRUD and binding behavior, including PyQueue.list_periodic.

Suggested labels: scheduler

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.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 accurately summarizes the main change: adding Python periodic-schedule catalog management.
Linked Issues check ✅ Passed The PR implements the linked issue’s Python API, async wrappers, return shape, tests, and docs updates.
Out of Scope Changes check ✅ Passed The changes stay focused on periodic-schedule catalog support and related documentation/tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/python-periodic-catalog

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/content/docs/shared/guides/core/scheduling.mdx`:
- Around line 369-372: Update the scheduling guide paragraph around
`run_worker()` and `@queue.periodic()` to clarify that producer-only processes
can still list and manage schedules already persisted in the shared backend.
Qualify the empty-list statement so it applies only to schedules newly declared
by that process, which remain absent until a worker registers them.

In `@sdks/python/taskito/mixins/periodic.py`:
- Around line 13-14: Update the periodic scheduling documentation near last_run
and next_run to state that timezone is None only when omitted, while an
explicitly supplied "UTC" remains preserved; clarify that omitted timezone
values default to UTC.

In `@sdks/python/tests/core/test_periodic.py`:
- Around line 37-46: Wrap the worker startup and poll_until setup in
teardown-safe cleanup so any exception before yield still calls queue.shutdown()
and joins the worker. Preserve the existing successful fixture flow while
ensuring the worker and database handle are released when poll_until fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f021e91c-9aa7-43a8-ab39-ec1fcefd3f95

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbac9e and a44f49d.

📒 Files selected for processing (10)
  • crates/taskito-python/src/py_queue/mod.rs
  • docs/content/docs/python/api-reference/queue/index.mdx
  • docs/content/docs/shared/guides/core/scheduling.mdx
  • sdks/python/taskito/__init__.py
  • sdks/python/taskito/_taskito.pyi
  • sdks/python/taskito/app.py
  • sdks/python/taskito/async_support/mixins.py
  • sdks/python/taskito/mixins/__init__.py
  • sdks/python/taskito/mixins/periodic.py
  • sdks/python/tests/core/test_periodic.py

Comment thread docs/content/docs/shared/guides/core/scheduling.mdx Outdated
Comment thread sdks/python/taskito/mixins/periodic.py Outdated
Comment thread sdks/python/tests/core/test_periodic.py Outdated
@pratyush618
pratyush618 merged commit 1cffd49 into master Jul 23, 2026
57 of 59 checks passed
@pratyush618
pratyush618 deleted the feat/python-periodic-catalog branch July 23, 2026 04:52
@pratyush618 pratyush618 mentioned this pull request Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose periodic-schedule catalog management in the Python SDK

2 participants