From 9a11f9aec71b754ffe392b47a4950bfbce669454 Mon Sep 17 00:00:00 2001 From: sun04222 <3242054475@qq.com> Date: Sat, 24 Oct 2026 13:31:12 +0800 Subject: [PATCH] fix(benchmark): guard the POSIX-only resource import in skill_export (#7381) skill_export.py imported the POSIX-only stdlib module `resource` unconditionally at module level, so the benchmark entry point died with ModuleNotFoundError on Windows before argument parsing. Mirror the try/except ImportError guard already established by checkpoint/checkpoint_bench_common.py, report "peak_rss_bytes": null when the module is unavailable, and leave POSIX scaling unchanged (macOS bytes, Linux KiB scaled to bytes). Fixes #7380 --- backend/scripts/benchmark/skill_export.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/scripts/benchmark/skill_export.py b/backend/scripts/benchmark/skill_export.py index cd5d23fff7..39cc758222 100644 --- a/backend/scripts/benchmark/skill_export.py +++ b/backend/scripts/benchmark/skill_export.py @@ -10,7 +10,6 @@ from __future__ import annotations import json import os -import resource import shutil import subprocess import sys @@ -19,6 +18,11 @@ import threading import time from pathlib import Path +try: + import resource +except ImportError: # pragma: no cover - Windows only + resource = None # type: ignore[assignment] + from deerflow.skills import export from deerflow.skills.storage.local_skill_storage import LocalSkillStorage @@ -112,7 +116,7 @@ def run(case): elapsed = time.perf_counter() - start finally: export.tempfile.TemporaryFile = tracker.original - rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss if resource is not None else None print( json.dumps( { @@ -120,7 +124,7 @@ def run(case): "outcome": outcome, "wall_seconds": round(elapsed, 4), "manifest_seconds": round(manifest_seconds, 4) if manifest_seconds is not None else None, - "peak_rss_bytes": rss if sys.platform == "darwin" else rss * 1024, + "peak_rss_bytes": (rss if sys.platform == "darwin" else rss * 1024) if rss is not None else None, "peak_temp_files": tracker.peak_count, "peak_temp_bytes": tracker.peak_bytes, "remaining_temp_files": sum(not file.closed for file in tracker.files),