Index: build/android/pylib/utils/test_environment.py |
diff --git a/build/android/pylib/utils/test_environment.py b/build/android/pylib/utils/test_environment.py |
index 279bc4a135c6acb043712a4c3d37425029ebaf13..33aedcddcdcb0859f9e778d62c3dbe45bb3724d6 100644 |
--- a/build/android/pylib/utils/test_environment.py |
+++ b/build/android/pylib/utils/test_environment.py |
@@ -5,19 +5,22 @@ |
import logging |
import os |
import psutil |
+import signal |
from pylib import android_commands |
def _KillWebServers(): |
for retry in xrange(5): |
- for server in ['lighttpd', 'web-page-replay']: |
- pids = [p.pid for p in psutil.process_iter() if server in p.name] |
- for pid in pids: |
+ for server in ['lighttpd', 'web-page-replay', 'webpagereplay']: |
tonyg
2013/12/06 17:49:53
Do we really need both with and without the dashes
bulach
2013/12/06 18:12:56
right, I think at some point it had the dashes, bu
|
+ for p in psutil.process_iter(): |
try: |
- logging.warning('Killing %s %s', server, pid) |
- os.kill(pid, signal.SIGQUIT) |
+ if not server in ' '.join(p.cmdline): |
+ continue |
+ logging.warning('Killing %s %s', server, p.pid) |
+ p.send_signal(signal.SIGQUIT) |
+ p.wait(1) |
tonyg
2013/12/06 17:49:53
I didn't think wait took args. What does this do?
tonyg
2013/12/06 17:49:53
Let's parallelize this by having two loops. The fi
bulach
2013/12/06 18:12:56
good idea!
the arg is a timeout for waiting the pr
|
except Exception as e: |
- logging.warning('Failed killing %s %s %s', server, pid, e) |
+ logging.warning('Failed killing %s %s %s', server, p.pid, e) |
def CleanupLeftoverProcesses(): |