From e034c0b3263fe6fa6607acbd8404a7107e478a97 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 30 Sep 2015 15:56:31 -0400 Subject: [PATCH] Fix proot controlpersist cleanup issue * Also removed psutil version and feature check from tasks. We now include the most recent version of psutil all around * Old versions of psutil must have had these Process() items as properties, they are functions now so we weren't properly evaluating them. With this change we are and things are back to working normally --- awx/plugins/callback/job_event_callback.py | 32 ++++------------------ 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/awx/plugins/callback/job_event_callback.py b/awx/plugins/callback/job_event_callback.py index 81f4a00b92..3c7a26b181 100644 --- a/awx/plugins/callback/job_event_callback.py +++ b/awx/plugins/callback/job_event_callback.py @@ -45,12 +45,7 @@ import requests # ZeroMQ import zmq -# PSUtil -try: - import psutil -except ImportError: - psutil = None - +import psutil class TokenAuth(requests.auth.AuthBase): @@ -249,19 +244,14 @@ class BaseCallbackModule(object): if not cp_files: return - # HACK: If psutil isn't available, sleep and allow the control master - # processes to timeout and die. - if not psutil: - time.sleep(60) - # Attempt to find any running control master processes. username = pwd.getpwuid(os.getuid())[0] ssh_cm_procs = [] for proc in psutil.process_iter(): try: - pname = proc.name - pcmdline = proc.cmdline - pusername = proc.username + pname = proc.name() + pcmdline = proc.cmdline() + pusername = proc.username() except psutil.NoSuchProcess: continue if pusername != username: @@ -277,19 +267,7 @@ class BaseCallbackModule(object): # version of psutil that may not have wait_procs implemented. for proc in ssh_cm_procs: proc.terminate() - if hasattr(psutil, 'wait_procs'): - procs_gone, procs_alive = psutil.wait_procs(ssh_cm_procs, timeout=5) - else: - procs_gone = [] - procs_alive = ssh_cm_procs[:] - for x in xrange(5): - for proc in procs_alive[:]: - if not proc.is_running(): - procs_alive.remove(proc) - procs_gone.append(proc) - if not procs_alive: - break - time.sleep(1) + procs_gone, procs_alive = psutil.wait_procs(ssh_cm_procs, timeout=5) for proc in procs_alive: proc.kill()