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()