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

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

Issue 62953024: [Telemetry] Refactor common Android cleanup functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 import os
7 import psutil
8
9 from pylib import android_commands
10 from pylib import ports
11
12 def _KillWebServers():
13 for retry in range(5):
14 for server in ['lighttpd', 'web-page-replay']:
15 pids = [p.pid for p in psutil.process_iter() if server in p.name]
16 for pid in pids:
17 try:
18 logging.warning('Killing %s %s', server, pid)
19 os.kill(pid, signal.SIGQUIT)
20 except Exception as e:
21 logging.warning('Failed killing %s %s %s', server, pid, e)
22
23
24 def CleanupPendingProcesses(restart_adb_as_root):
tonyg 2013/11/15 05:45:10 Please add a docstring
Primiano Tucci (use gerrit) 2013/11/19 18:13:03 Done.
25 _KillWebServers()
26 did_restart_host_adb = False
27 for device in android_commands.GetAttachedDevices():
28 adb = android_commands.AndroidCommands(device)
29 # Make sure we restart the host adb server only once.
30 if not did_restart_host_adb:
31 adb.RestartAdbServer()
32 did_restart_host_adb = True
33 adb.RestartAdbdOnDevice()
34 if restart_adb_as_root:
35 adb.EnableAdbRoot()
36 adb.WaitForDevicePm()
37
38 # Reset the test port allocation. It's important to do it before starting
39 # to dispatch any step.
40 if not ports.ResetTestServerPortAllocation():
41 raise Exception('Failed to reset test server port.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698