diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-08-02 01:10:19 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-08-02 01:23:38 +0200 |
commit | 92e1a2209ff072f1b72d1bf62cf83f129973b1ff (patch) | |
tree | 0410795d950c23b1407ce81f3c6f2fdff69a3b15 /test | |
parent | 9ae4337be55788314c1342d89c4186f8647a6b52 (diff) | |
download | rspamd-92e1a2209ff072f1b72d1bf62cf83f129973b1ff.tar.gz rspamd-92e1a2209ff072f1b72d1bf62cf83f129973b1ff.zip |
[Test] Replace get_process_children with psutil function
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/lib/rspamd.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index 3556a4b58..c40ac588c 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -24,18 +24,6 @@ def cleanup_temporary_directory(directory): def encode_filename(filename): return "".join(['%%%0X' % ord(b) for b in filename]) -def get_process_children(pid): - children = [] - for p in psutil.process_iter(): - # ppid could be int or function depending on library version - if callable(p.ppid): - ppid = p.ppid() - else: - ppid = p.ppid - if ppid == pid: - children.append(p.pid) - return children - def get_test_directory(): return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "../../") @@ -136,7 +124,7 @@ def shutdown_process(pid): def shutdown_process_with_children(pid): pid = int(pid) - children = get_process_children(pid) + children = psutil.Process(pid=pid).children(recursive=False) shutdown_process(pid) for child in children: - shutdown_process(child) + shutdown_process(child.pid) |