feature: centralizes Celery task handling in shared helpers and configures result expiration#70
Merged
JoeGaffney merged 2 commits intomainfrom Jan 23, 2026
Merged
feature: centralizes Celery task handling in shared helpers and configures result expiration#70JoeGaffney merged 2 commits intomainfrom
JoeGaffney merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes Celery task handling in shared helpers and configures result expiration, while simplifying the API routers to use the new helpers and common settings.
Changes:
- Add a
result_expires_dayssetting in both API and worker configs and wire it into the Celery app configuration to control task result TTL. - Introduce
create_taskandget_task_detailedhelpers inapi/common/task_helpers.py, and refactor the images, videos, texts, and workflows routers to use them instead of directcelery_appaccess. - Improve task introspection by combining queue-position lookup and Flower metadata, and change the behavior for unknown/expired tasks to return a 404 instead of a "task not found" log with 200.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
workers/common/config.py |
Adds result_expires_days setting for worker-side Celery result expiry. |
workers/worker.py |
Configures worker Celery app to expire results based on settings.result_expires_days. |
api/common/config.py |
Adds API-side result_expires_days setting to keep API and worker Celery configs aligned. |
api/worker.py |
Configures API Celery client to use result_expires_days for result expiry. |
api/common/task_helpers.py |
Refactors task utilities to include a unified create_task, a richer get_task_detailed (with Flower and Redis queue info plus 404 on missing tasks), and a simplified cancel_task. |
api/images/router.py |
Refactors image endpoints to use create_task/get_task_detailed and the new cancel_task signature, while preserving response models and behavior. |
api/videos/router.py |
Same refactor pattern as images router for video task creation, polling, and cancellation. |
api/texts/router.py |
Refactors text endpoints to use the shared helpers, simplifying task creation and polling. |
api/workflows/router.py |
Refactors workflow endpoints to use the shared helpers and maintain signed URL generation for outputs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.