]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Replace get_process_children with psutil function 787/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 1 Aug 2016 23:10:19 +0000 (01:10 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 1 Aug 2016 23:23:38 +0000 (01:23 +0200)
circle.yml
test/functional/lib/rspamd.py

index 7fb9e4a918e6fc4402d74f5842f15300143caaff..c08a8d5e4bd3ae722d39db00f1dfc3aab0d20318 100644 (file)
@@ -1,7 +1,8 @@
 dependencies:
     pre:
       - sudo apt-get update -qq
-      - sudo apt-get install -qq cmake gcc libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make python-psutil ragel redis-server
+      - sudo apt-get install -qq cmake gcc libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make python-dev ragel redis-server
+      - sudo pip install psutil
       - sudo pip install robotframework
 
 test:
index 3556a4b58d17c0745680b219cc24f0e79366541d..c40ac588c3a1b51f79e655f34d1c039b9f68b0d6 100644 (file)
@@ -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)