summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2021-09-08 12:26:51 -0400
committerGitHub <noreply@github.com>2021-09-08 12:26:51 -0400
commit75ec7bdb5dfc8c68ee8c50d19ac456ccd002b2bc (patch)
tree563fc51311000feac01d82f8abd563de1ea5818a
parent4fcda740dc8bc029697feba2936ba41487264450 (diff)
parent20b31fffc1e9f3b655a304b73ab3872768fb4a3b (diff)
Merge pull request #9572 from LabNConsulting/chopps/fix-cleanup
tests: deal with parallel exit of process we are reaping
-rw-r--r--tests/topotests/lib/micronet_compat.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/topotests/lib/micronet_compat.py b/tests/topotests/lib/micronet_compat.py
index 31a76aca55..a3d3f4c685 100644
--- a/tests/topotests/lib/micronet_compat.py
+++ b/tests/topotests/lib/micronet_compat.py
@@ -33,16 +33,22 @@ def get_pids_with_env(has_var, has_val=None):
result = {}
for pidenv in glob.iglob("/proc/*/environ"):
pid = pidenv.split("/")[2]
- with open(pidenv, "rb") as rfb:
- envlist = [x.decode("utf-8").split("=", 1) for x in rfb.read().split(b"\0")]
- envlist = [[x[0], ""] if len(x) == 1 else x for x in envlist]
- envdict = dict(envlist)
- if has_var not in envdict:
- continue
- if has_val is None:
- result[pid] = envdict
- elif envdict[has_var] == str(has_val):
- result[pid] = envdict
+ try:
+ with open(pidenv, "rb") as rfb:
+ envlist = [
+ x.decode("utf-8").split("=", 1) for x in rfb.read().split(b"\0")
+ ]
+ envlist = [[x[0], ""] if len(x) == 1 else x for x in envlist]
+ envdict = dict(envlist)
+ if has_var not in envdict:
+ continue
+ if has_val is None:
+ result[pid] = envdict
+ elif envdict[has_var] == str(has_val):
+ result[pid] = envdict
+ except Exception:
+ # E.g., process exited and files are gone
+ pass
return result