Skip to content

Distinguish worker-shutdown 503s from queue-full 503s - #73

Merged
nosyndicate merged 2 commits into
mainfrom
phase4_25
Jul 4, 2026
Merged

Distinguish worker-shutdown 503s from queue-full 503s#73
nosyndicate merged 2 commits into
mainfrom
phase4_25

Conversation

@nosyndicate

@nosyndicate nosyndicate commented Jul 4, 2026

Copy link
Copy Markdown
Owner

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.

  • Define WorkerShuttingDown(RuntimeError) in server/executor/worker.py
  • Raise the new exception from Worker.submit when the shutdown event is set
  • Catch WorkerShuttingDown in _submit_or_fail, returning a 503 with a worker-shutdown-specific message
  • Add tests/api/test_routes.py covering shutdown, queue-full, and happy-path cases through _submit_or_fail
  • Update tests/executor/test_worker.py to assert the new exception type

@nosyndicate nosyndicate changed the title add a new error type to indicate the true issue Introduce WorkerShuttingDown exception for clearer 503s Jul 4, 2026
@nosyndicate
nosyndicate marked this pull request as ready for review July 4, 2026 05:56
Copilot AI review requested due to automatic review settings July 4, 2026 05:56

Copilot AI 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.

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 from Worker.submit() when the shutdown event is set.
  • Updated API submission path (_submit_or_fail) to catch WorkerShuttingDown and 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 thread server/executor/worker.py
@nosyndicate nosyndicate changed the title Introduce WorkerShuttingDown exception for clearer 503s Distinguish worker-shutdown 503s from queue-full 503s Jul 4, 2026
@nosyndicate
nosyndicate requested a review from Copilot July 4, 2026 06:33

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread server/api/routes.py
Comment on lines +227 to +231
except WorkerShuttingDown:
raise HTTPException(
status_code=503,
detail="Worker is shutting down. Please try again later.",
)
@nosyndicate
nosyndicate merged commit e4c5339 into main Jul 4, 2026
1 check passed
@nosyndicate
nosyndicate deleted the phase4_25 branch July 4, 2026 06:39
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.

2 participants