LitServe
LitServe copied to clipboard
fix: wait for worker setup complete in wrap_litserve_start
What does this PR do?
Prevents TestClient.post() hang when worker setup() is slow.
Added a worker readiness wait loop to wrap_litserve_start() in
src/litserve/utils.py, ensuring all workers have completed setup()
before the context manager yields control.
Why
wrap_litserve_start() launched inference workers but never waited for
them to finish setup(). When model loading took >0 seconds, the worker
wasn't listening yet and TestClient.post() hung indefinitely.
LitServer.run() already had this check — this PR brings the same
behavior to wrap_litserve_start().
How
Added the readiness check before try: yield server:
- Waits for all workers to reach
WorkerSetupStatus.READY - Raises
RuntimeErrorif any worker fails - Polls every 50ms to avoid busy-waiting
Closes #681