LitServe icon indicating copy to clipboard operation
LitServe copied to clipboard

fix: wait for worker setup complete in wrap_litserve_start

Open hesam-oxe opened this issue 6 months ago • 0 comments

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 RuntimeError if any worker fails
  • Polls every 50ms to avoid busy-waiting

Closes #681

hesam-oxe avatar May 10 '26 04:05 hesam-oxe