File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,7 @@ def _init_engine(self):
228228 # Run the engine in a separate thread running the AsyncIO event loop.
229229 self ._llm_engine = None
230230 self ._llm_engine_start_cv = threading .Condition ()
231- self ._llm_engine_shutdown_event = threading .Event ()
231+ self ._llm_engine_shutdown_event = asyncio .Event ()
232232 self ._event_thread = threading .Thread (
233233 target = asyncio .run , args = (self ._run_llm_engine (),)
234234 )
@@ -268,8 +268,7 @@ async def _run_llm_engine(self):
268268 self ._llm_engine_start_cv .notify_all ()
269269
270270 # Wait for the engine shutdown signal.
271- while not self ._llm_engine_shutdown_event .is_set ():
272- await asyncio .sleep (0.1 ) # Prevent busy-waiting
271+ await self ._llm_engine_shutdown_event .wait ()
273272
274273 # Wait for the ongoing requests to complete.
275274 while self ._ongoing_request_count > 0 :
@@ -801,7 +800,7 @@ def _check_health(self, requests):
801800
802801 def finalize (self ):
803802 self .logger .log_info ("[vllm] Issuing finalize to vllm backend" )
804- self ._llm_engine_shutdown_event .set ( )
803+ self ._event_loop . call_soon_threadsafe ( self . _llm_engine_shutdown_event .set )
805804
806805 # Shutdown the event thread.
807806 if self ._event_thread is not None :
You can’t perform that action at this time.
0 commit comments