Skip to content

Commit

Permalink
replasing asyncio event with threading event
Browse files Browse the repository at this point in the history
  • Loading branch information
oandreeva-nv committed Dec 20, 2024
1 parent cd4cf06 commit 0e6f5ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ci/L0_backend_vllm/metrics_test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ run_test() {
fi
fi

set -e

# TODO: Non-graceful shutdown when metrics are enabled.
kill $SERVER_PID
wait $SERVER_PID

set -e
}

RET=0
Expand Down
5 changes: 3 additions & 2 deletions src/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _init_engine(self):
# Run the engine in a separate thread running the AsyncIO event loop.
self._llm_engine = None
self._llm_engine_start_cv = threading.Condition()
self._llm_engine_shutdown_event = asyncio.Event()
self._llm_engine_shutdown_event = threading.Event()
self._event_thread = threading.Thread(
target=asyncio.run, args=(self._run_llm_engine(),)
)
Expand Down Expand Up @@ -268,7 +268,8 @@ async def _run_llm_engine(self):
self._llm_engine_start_cv.notify_all()

# Wait for the engine shutdown signal.
await self._llm_engine_shutdown_event.wait()
while not self._llm_engine_shutdown_event.is_set():
await asyncio.sleep(0.1) # Prevent busy-waiting

# Wait for the ongoing requests to complete.
while self._ongoing_request_count > 0:
Expand Down

0 comments on commit 0e6f5ef

Please sign in to comment.