From 7607e4d18055766c45bc019dd354f20b1509e6e6 Mon Sep 17 00:00:00 2001 From: Tarushii Goel Date: Tue, 21 Apr 2026 20:45:52 -0700 Subject: [PATCH] py-spy without `--native` for ARM devices (#23410) --- python/sglang/srt/utils/common.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/python/sglang/srt/utils/common.py b/python/sglang/srt/utils/common.py index a56916f09..34403ab17 100644 --- a/python/sglang/srt/utils/common.py +++ b/python/sglang/srt/utils/common.py @@ -2338,16 +2338,18 @@ def human_readable_int(value: str) -> int: def pyspy_dump_schedulers(): """py-spy dump on all scheduler in a local node.""" - try: - pid = psutil.Process().pid - # Command to run py-spy with the PID - cmd = f"py-spy dump --native --pid {pid}" - result = subprocess.run( - cmd, shell=True, capture_output=True, text=True, check=True - ) - logger.error(f"Pyspy dump for PID {pid}:\n{result.stdout}") - except subprocess.CalledProcessError as e: - logger.error(f"Pyspy failed to dump PID {pid}. Error: {e.stderr}") + pid = psutil.Process().pid + for attempt, native_flag in enumerate(["--native", ""]): + try: + cmd = f"py-spy dump {native_flag} --pid {pid}".strip() + result = subprocess.run( + cmd, shell=True, capture_output=True, text=True, check=True + ) + logger.error(f"Pyspy dump for PID {pid} ({cmd}):\n{result.stdout}") + return + except subprocess.CalledProcessError as e: + logger.error(f"Pyspy failed ({cmd}). Error: {e.stderr}") + logger.error(f"All pyspy dump attempts failed for PID {pid}.") def kill_itself_when_parent_died():