From a0d6897fb2157e5738dfde22ff56fd27ae410759 Mon Sep 17 00:00:00 2001 From: Fei Deng Date: Wed, 10 Feb 2021 12:06:37 -0600 Subject: [PATCH] replace psutil.pid() with psutil.process_iter() for safer execution --- tests/gold_tests/thread_config/check_threads.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/gold_tests/thread_config/check_threads.py b/tests/gold_tests/thread_config/check_threads.py index 975e95f8791..7ebfb808cfa 100755 --- a/tests/gold_tests/thread_config/check_threads.py +++ b/tests/gold_tests/thread_config/check_threads.py @@ -23,12 +23,11 @@ def count_threads(ts_path, etnet_threads, accept_threads, task_threads, aio_threads): - for pid in psutil.pids(): + for p in psutil.process_iter(['name', 'cwd', 'threads']): # Find the pid corresponding to the ats process we started in autest. # It needs to match the process name and the binary path. # If autest can expose the pid of the process this is not needed anymore. - p = psutil.Process(pid) if p.name() == '[TS_MAIN]' and p.cwd() == ts_path: etnet_check = set()