Skip to content

Commit 9f3bc0f

Browse files
authored
[MISC][V1] Register process killing handler only in the main thread (#14380)
Signed-off-by: Cody Yu <[email protected]>
1 parent 980385f commit 9f3bc0f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vllm/v1/engine/core_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import queue
66
import signal
7+
import threading
78
import uuid
89
import weakref
910
from abc import ABC, abstractmethod
@@ -260,7 +261,14 @@ def sigusr1_handler(signum, frame):
260261
"down. See stack trace above for root cause issue.")
261262
kill_process_tree(os.getpid())
262263

263-
signal.signal(signal.SIGUSR1, sigusr1_handler)
264+
if threading.current_thread() == threading.main_thread():
265+
signal.signal(signal.SIGUSR1, sigusr1_handler)
266+
else:
267+
logger.warning("SIGUSR1 handler not installed because we are not "
268+
"running in the main thread. In this case the "
269+
"forked engine process may not be killed when "
270+
"an exception is raised, and you need to handle "
271+
"the engine process shutdown manually.")
264272

265273
# Serialization setup.
266274
self.encoder = MsgpackEncoder()

0 commit comments

Comments
 (0)