Distinguish worker-shutdown 503s from queue-full 503s - #73
Merged
Conversation
nosyndicate
marked this pull request as ready for review
July 4, 2026 05:56
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated WorkerShuttingDown exception to replace a generic RuntimeError when submitting work during shutdown, allowing the FastAPI layer to return a clearer, actionable 503 response.
Changes:
- Added
WorkerShuttingDown(RuntimeError)and raised it fromWorker.submit()when the shutdown event is set. - Updated API submission path (
_submit_or_fail) to catchWorkerShuttingDownand return a shutdown-specific 503 response.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
server/executor/worker.py |
Adds the WorkerShuttingDown exception and raises it on submit during shutdown. |
server/api/routes.py |
Catches WorkerShuttingDown in _submit_or_fail and returns a specific 503 error message. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+227
to
+231
| except WorkerShuttingDown: | ||
| raise HTTPException( | ||
| status_code=503, | ||
| detail="Worker is shutting down. Please try again later.", | ||
| ) |
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.
The API previously returned identical 503s for two unrelated conditions: the worker draining during shutdown and the inbound queue being full. Split these into separate exception and response paths so callers get an accurate reason.
WorkerShuttingDown(RuntimeError)inserver/executor/worker.pyWorker.submitwhen the shutdown event is setWorkerShuttingDownin_submit_or_fail, returning a 503 with a worker-shutdown-specific messagetests/api/test_routes.pycovering shutdown, queue-full, and happy-path cases through_submit_or_failtests/executor/test_worker.pyto assert the new exception type