One package that makes the POSIX assumptions measured in W0-W8 hold in every process vLLM / vLLM-Omni starts, and reports what it did: - provides fcntl (flock/lockf on msvcrt.locking; LOCK_SH served as exclusive) and uvloop (asyncio.run on a selector loop) when absent; - installs WindowsSelectorEventLoopPolicy and a signal.signal fallback for loop.add_signal_handler on the Windows loop classes; - replaces whole vLLM's get_open_zmq_ipc_path / find_loaded_library when the wheel lacks the branch patch and the upstream body hash is known; - verifies the wheel-only sites (sentinel poll, int64 seed) and reports wheel_required at the exact site instead of failing downstream; - shm_dir() replaces the /dev/shm literals; os.geteuid provided. Activated from vllm_omni/patch.py and as vllm.general_plugins / vllm_omni.general_plugins entry points (idempotent; no-op off Windows). prints the audit; the M0 placement report embeds it. 16 Linux tests through injected primitives. Design: analysis/design_windows_compat_plugin_20260921.md Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
|
"""Process helpers that work on every OS (no ``os.killpg``, no ``kill -9``)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
|
|
|
|
def kill_tree(pid: int, *, timeout: float = 30.0) -> dict[str, int]:
|
|
"""Terminate ``pid`` and every descendant; escalate to kill after ``timeout``.
|
|
|
|
Returns counts: ``{"terminated": n, "killed": m}``. Missing processes are
|
|
not an error (the tree may already be gone).
|
|
"""
|
|
import psutil
|
|
|
|
try:
|
|
parent = psutil.Process(pid)
|
|
except psutil.NoSuchProcess:
|
|
return {"terminated": 0, "killed": 0}
|
|
procs = [*parent.children(recursive=True), parent]
|
|
for p in procs:
|
|
try:
|
|
p.terminate()
|
|
except psutil.NoSuchProcess:
|
|
pass
|
|
_, alive = psutil.wait_procs(procs, timeout=timeout)
|
|
for p in alive:
|
|
try:
|
|
p.kill()
|
|
except psutil.NoSuchProcess:
|
|
pass
|
|
return {"terminated": len(procs) - len(alive), "killed": len(alive)}
|
|
|
|
|
|
def kill_popen_tree(proc: subprocess.Popen, *, timeout: float = 30.0) -> dict[str, int]:
|
|
return kill_tree(proc.pid, timeout=timeout)
|