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
3 # found in the LICENSE file.
9 from devil
.android
import device_errors
10 from devil
.android
import device_utils
13 def _KillWebServers():
14 for s
in [signal
.SIGTERM
, signal
.SIGINT
, signal
.SIGQUIT
, signal
.SIGKILL
]:
16 for server
in ['lighttpd', 'webpagereplay']:
17 for p
in psutil
.process_iter():
19 if not server
in ' '.join(p
.cmdline
):
21 logging
.info('Killing %s %s %s', s
, server
, p
.pid
)
24 except Exception: # pylint: disable=broad-except
25 logging
.exception('Failed killing %s %s', server
, p
.pid
)
29 except Exception: # pylint: disable=broad-except
30 logging
.exception('Failed waiting for %s to die.', p
.pid
)
33 def CleanupLeftoverProcesses(devices
):
34 """Clean up the test environment, restarting fresh adb and HTTP daemons.
37 devices: The devices to clean.
40 device_utils
.RestartServer()
42 def cleanup_device(d
):
46 except device_errors
.CommandFailedError
:
47 logging
.exception('Failed to enable root')
48 d
.WaitUntilFullyBooted()
50 device_utils
.DeviceUtils
.parallel(devices
).pMap(cleanup_device
)