[llvm] [lit] Stop holding subprocess objects open in TimeoutHelper (PR #186712)
Nick Begg via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 15 15:52:15 PDT 2026
https://github.com/neek78 created https://github.com/llvm/llvm-project/pull/186712
Tweak TestRunner's TimeoutHelper storage to hold only PIDs rather
than the whole process object. Holding the object causes many pipes to
stay open, when all we need is the pid.
Addresses #185941
>From 3e900b72f5bc39f5bf44b5f434fa5e0b54e1bb84 Mon Sep 17 00:00:00 2001
From: Nick Begg <nick at stunttruck.net>
Date: Sun, 15 Mar 2026 23:39:22 +0100
Subject: [PATCH] [lit] Stop holding subprocess objects open in TimeoutHelper
Tweak TestRunner's TimeoutHelper storage to hold only PIDs rather
than the whole process object. Holding the object causes many pipes to
stay open, when all we need is the pid.
Addresses #185941
---
llvm/utils/lit/lit/TestRunner.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 9e7d64a5ea8c5..d856642e3f447 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -135,7 +135,9 @@ def addProcess(self, proc):
return
needToRunKill = False
with self._lock:
- self._procs.append(proc)
+ # just store the pid, rather than the whole proc object.
+ # Holding the proc object keeps resources (eg pipes) open unnecessarily.
+ self._procs.append(proc.pid)
# Avoid re-entering the lock by finding out if kill needs to be run
# again here but call it if necessary once we have left the lock.
# We could use a reentrant lock here instead but this code seems
@@ -175,8 +177,8 @@ def _kill(self):
the initial call to _kill()
"""
with self._lock:
- for p in self._procs:
- lit.util.killProcessAndChildren(p.pid)
+ for pid in self._procs:
+ lit.util.killProcessAndChildren(pid)
# Empty the list and note that we've done a pass over the list
self._procs = [] # Python2 doesn't have list.clear()
self._doneKillPass = True
More information about the llvm-commits
mailing list