You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/02/10 18:22:24 UTC
[GitHub] [trafficserver] bneradt commented on a change in pull request #7515: Replace psutil.pid() with psutil.process_iter() for safer execution
bneradt commented on a change in pull request #7515:
URL: https://github.com/apache/trafficserver/pull/7515#discussion_r573966469
##########
File path: 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():
Review comment:
Looks good.
As a tweak, reading the docs, it looks like the preferable way to do this is by passing in the subset of process attributes that are desired. In this case, perhaps:
```
for p in psutil.process_iter(['name', 'cwd', 'threads']):
...
p.info['name'] == '[TS_MAIN]' and p.info['cwd'] == ts_path:
...
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org