Add task_expires_seconds for async endpoint task expiration#754
Open
lukasewecker wants to merge 1 commit intomainfrom
Open
Add task_expires_seconds for async endpoint task expiration#754lukasewecker wants to merge 1 commit intomainfrom
lukasewecker wants to merge 1 commit intomainfrom
Conversation
Add configurable task expiration for async endpoints, allowing users to specify how long a task can wait in the queue before being discarded by Celery workers. Defaults to 86400 seconds (24 hours) if not specified. Changes: - Add task_expires_seconds field to DTOs, entities, and ORM model - Pass expires parameter to Celery task queue gateway - Add K8s annotations for celery autoscaler configuration - Include database migration for new column - Add comprehensive unit tests for the feature Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dmchoiboi
reviewed
Feb 12, 2026
| self, | ||
| topic: str, | ||
| predict_request: EndpointPredictV1Request, | ||
| task_timeout_seconds: int, |
Collaborator
There was a problem hiding this comment.
I believe this is being used in async_inference_use_cases.py
Collaborator
Author
There was a problem hiding this comment.
I just renamed the parameter to task_expires_seconds here. Can you explain more what you mean?
Collaborator
There was a problem hiding this comment.
oh i was mentioning that this is currently used in https://github.com/scaleapi/llm-engine/blob/main/model-engine/model_engine_server/domain/use_cases/async_inference_use_cases.py#L72
Collaborator
Author
There was a problem hiding this comment.
The issue was that it wasnt properly passed down to when celery creates the task:
Also it wasnt possible to configure this parameter. So basically what I did was
- rename it (you could argue if thats necessary)
- pass it down properly to downstream code
- make it configurable from outside
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.
Pull Request Summary
Add configurable task expiration for async endpoints, allowing users to specify how long a task can wait in the queue before being discarded by Celery workers. Defaults to 86400 seconds (24 hours) if not specified.
Keep in mind that this change does not automatically discard a task from the queue once it is stale. It only marks a task as stale, which then waits in the queue to be picked up by the worker. Once picked up by a worker, the worker then notices that the task is stale and will not process it. This means that when a stale task is never picked up by the worker (e.g. no worker is available), it stays in the queue.
Changes:
Note
alembic update head).task_timeout_secondsbefore, which was not used in the downstream tasks though. It was all renamed totask_expires_seconds, and is now passed properly to the celery tasks.Example API usage
When creating a new model endpoint via the api, you can now pass the parameter:
Test Plan and Usage Guide
Ran unit tests and added new tests for the new feature.
Also, tested locally with this script (spun up Redis locally):