Skip to content

Commit 4de454a

Browse files
fix(bench): temp-tree cleanup survives output errors and stubborn files — no more /tmp husks
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent de239eb commit 4de454a

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

scripts/validation/git-workload-benchmark.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,9 @@ def main(argv: list[str]) -> int:
11261126
if args.keep_temp:
11271127
temp_root = Path(tempfile.mkdtemp(prefix="agentfs-git-workload-"))
11281128
else:
1129-
temp_manager = tempfile.TemporaryDirectory(prefix="agentfs-git-workload-")
1129+
temp_manager = tempfile.TemporaryDirectory(
1130+
prefix="agentfs-git-workload-", ignore_cleanup_errors=True
1131+
)
11301132
temp_root = Path(temp_manager.name)
11311133

11321134
exit_code = 0
@@ -1351,15 +1353,18 @@ def main(argv: list[str]) -> int:
13511353
"kept_temp": bool(args.keep_temp),
13521354
}
13531355

1354-
payload = json.dumps(result, indent=args.json_indent, sort_keys=True) + "\n"
1355-
if args.output:
1356-
Path(args.output).expanduser().write_text(payload, encoding="utf-8")
1357-
print(f"Wrote Git workload benchmark JSON to {args.output}", file=sys.stderr)
1358-
else:
1359-
sys.stdout.write(payload)
1360-
1361-
if temp_manager is not None:
1362-
temp_manager.cleanup()
1356+
try:
1357+
payload = json.dumps(result, indent=args.json_indent, sort_keys=True) + "\n"
1358+
if args.output:
1359+
Path(args.output).expanduser().write_text(payload, encoding="utf-8")
1360+
print(f"Wrote Git workload benchmark JSON to {args.output}", file=sys.stderr)
1361+
else:
1362+
sys.stdout.write(payload)
1363+
finally:
1364+
# Not the context-manager protocol, but cleanup must survive output
1365+
# errors too; retried husks previously accumulated in /tmp.
1366+
if temp_manager is not None:
1367+
temp_manager.cleanup()
13631368

13641369
return exit_code
13651370

0 commit comments

Comments
 (0)