From 60c542a68c04e5aacee87e1d8bebe30012838c6c Mon Sep 17 00:00:00 2001 From: Cody Yu Date: Thu, 6 Mar 2025 10:50:22 -0800 Subject: [PATCH] fix Signed-off-by: Cody Yu --- vllm/v1/engine/core_client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vllm/v1/engine/core_client.py b/vllm/v1/engine/core_client.py index 55057179f3a4..d060d9778e75 100644 --- a/vllm/v1/engine/core_client.py +++ b/vllm/v1/engine/core_client.py @@ -4,6 +4,7 @@ import os import queue import signal +import threading import uuid import weakref from abc import ABC, abstractmethod @@ -260,7 +261,14 @@ def sigusr1_handler(signum, frame): "down. See stack trace above for root cause issue.") kill_process_tree(os.getpid()) - signal.signal(signal.SIGUSR1, sigusr1_handler) + if threading.current_thread() == threading.main_thread(): + signal.signal(signal.SIGUSR1, sigusr1_handler) + else: + logger.warning("SIGUSR1 handler not installed because we are not " + "running in the main thread. In this case the " + "forked engine process may not be killed when " + "an exception is raised, and you need to handle " + "the engine process shutdown manually.") # Serialization setup. self.encoder = MsgpackEncoder()