Skip to content

fix(procrastinate): track periodic tasks via job_manager.defer_periodic_job#49

Merged
snopoke merged 1 commit into
mainfrom
sk/procrastinate-periodic-tracking
May 26, 2026
Merged

fix(procrastinate): track periodic tasks via job_manager.defer_periodic_job#49
snopoke merged 1 commit into
mainfrom
sk/procrastinate-periodic-tracking

Conversation

@snopoke
Copy link
Copy Markdown
Collaborator

@snopoke snopoke commented May 26, 2026

Procrastinate's PeriodicDeferrer enqueues jobs by calling app.job_manager.defer_periodic_job(job=...) directly, bypassing task.defer/defer_async. Our integration only wrapped the latter, so @app.periodic tasks ran with zero TaskBadger visibility — no PENDING task at enqueue, no status updates from the worker (the __taskbadger_task_id__ kwarg was never injected).

Fix patches app.job_manager.defer_periodic_job per-app: looks up the task by job.task_name, runs the same auto/manual/includes/excludes gate as the regular defer path, and uses job.evolve(task_kwargs=...) to inject the TB id. Worker-side wrapper is unchanged.

Known edge case left as follow-up: if defer_periodic_job returns None (race — another worker already deferred the same (task, periodic_id, timestamp)), the PENDING TB task we created becomes orphaned. Only happens under multi-worker contention.

🤖 Generated with Claude Code

…ic_job

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@snopoke snopoke marked this pull request as ready for review May 26, 2026 14:36
@snopoke snopoke merged commit ce5baa1 into main May 26, 2026
8 of 12 checks passed
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.

1 participant