diff --git a/python/sglang/srt/multimodal/processors/base_processor.py b/python/sglang/srt/multimodal/processors/base_processor.py index 4e160a764c..dfb560a919 100644 --- a/python/sglang/srt/multimodal/processors/base_processor.py +++ b/python/sglang/srt/multimodal/processors/base_processor.py @@ -1,6 +1,7 @@ import asyncio import concurrent import concurrent.futures +import concurrent.futures.process import dataclasses import multiprocessing as mp import os @@ -212,6 +213,13 @@ def _tokenizer_of(processor): return processor.tokenizer if hasattr(processor, "tokenizer") else processor +def _forget_parent_executor_wakeups(): + # A forked worker inherits the parent's executor wakeups, whose locks a parent + # thread may hold at fork time; since Python 3.12.8 / 3.13.1 the worker's exit + # hook takes those locks, so the worker would never exit. + concurrent.futures.process._threads_wakeups.clear() + + class BaseMultimodalProcessor(ABC): models = [] gpu_image_decode = True # Enable GPU decoding by default @@ -508,6 +516,7 @@ class BaseMultimodalProcessor(ABC): return concurrent.futures.ProcessPoolExecutor( mp_context=mp.get_context(start_method), max_workers=int(os.environ.get("SGLANG_CPU_WORKERS", os.cpu_count())), + initializer=_forget_parent_executor_wakeups, ) def _replace_broken_cpu_executor(