From e41e1602630f49a4f1678a976985b6a9355b58da Mon Sep 17 00:00:00 2001 From: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:23:02 -0400 Subject: [PATCH] [V1] Guard Against Main Thread Usage (#14972) Signed-off-by: rshaw@neuralmagic.com --- vllm/engine/arg_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index 49b8b0d5ca13d..de85c2b206acf 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -3,6 +3,7 @@ import argparse import dataclasses import json +import threading from dataclasses import dataclass from typing import (TYPE_CHECKING, Any, Dict, List, Literal, Mapping, Optional, Tuple, Type, Union, cast, get_args) @@ -1576,6 +1577,11 @@ class EngineArgs: ############################################################# # Experimental Features - allow users to opt in. + # Signal Handlers requires running in main thread. + if (threading.current_thread() != threading.main_thread() + and _warn_or_fallback("Engine in background thread")): + return False + # LoRA is supported on V1, but off by default for now. if self.enable_lora and _warn_or_fallback("LORA"): return False