Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: build/android/pylib/utils/test_environment.py

Issue 105733013: Android: kill leftover webpagereplay servers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import psutil 7 import psutil
8 import signal
8 9
9 from pylib import android_commands 10 from pylib import android_commands
10 11
12
11 def _KillWebServers(): 13 def _KillWebServers():
12 for retry in xrange(5): 14 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]:
13 for server in ['lighttpd', 'web-page-replay']: 15 signalled = []
14 pids = [p.pid for p in psutil.process_iter() if server in p.name] 16 for server in ['lighttpd', 'webpagereplay']:
15 for pid in pids: 17 for p in psutil.process_iter():
16 try: 18 try:
17 logging.warning('Killing %s %s', server, pid) 19 if not server in ' '.join(p.cmdline):
18 os.kill(pid, signal.SIGQUIT) 20 continue
21 logging.info('Killing %s %s %s', s, server, p.pid)
22 p.send_signal(s)
23 signalled.append(p)
19 except Exception as e: 24 except Exception as e:
20 logging.warning('Failed killing %s %s %s', server, pid, e) 25 logging.warning('Failed killing %s %s %s', server, p.pid, e)
26 for p in signalled:
27 try:
28 p.wait(1)
29 except Exception as e:
30 logging.warning('Failed waiting for %s to die. %s', p.pid, e)
31
21 32
22 33
23 def CleanupLeftoverProcesses(): 34 def CleanupLeftoverProcesses():
24 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" 35 """Clean up the test environment, restarting fresh adb and HTTP daemons."""
25 _KillWebServers() 36 _KillWebServers()
26 did_restart_host_adb = False 37 did_restart_host_adb = False
27 for device in android_commands.GetAttachedDevices(): 38 for device in android_commands.GetAttachedDevices():
28 adb = android_commands.AndroidCommands(device, api_strict_mode=True) 39 adb = android_commands.AndroidCommands(device, api_strict_mode=True)
29 # Make sure we restart the host adb server only once. 40 # Make sure we restart the host adb server only once.
30 if not did_restart_host_adb: 41 if not did_restart_host_adb:
31 adb.RestartAdbServer() 42 adb.RestartAdbServer()
32 did_restart_host_adb = True 43 did_restart_host_adb = True
33 adb.RestartAdbdOnDevice() 44 adb.RestartAdbdOnDevice()
34 adb.EnableAdbRoot() 45 adb.EnableAdbRoot()
35 adb.WaitForDevicePm() 46 adb.WaitForDevicePm()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698