OLD | NEW |
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 psutil | 6 import psutil |
7 import signal | 7 import signal |
8 | 8 |
9 from pylib.device import device_errors | 9 from pylib.device import device_errors |
10 from pylib.device import device_utils | 10 from pylib.device import device_utils |
(...skipping 12 matching lines...) Expand all Loading... |
23 signalled.append(p) | 23 signalled.append(p) |
24 except Exception as e: | 24 except Exception as e: |
25 logging.warning('Failed killing %s %s %s', server, p.pid, e) | 25 logging.warning('Failed killing %s %s %s', server, p.pid, e) |
26 for p in signalled: | 26 for p in signalled: |
27 try: | 27 try: |
28 p.wait(1) | 28 p.wait(1) |
29 except Exception as e: | 29 except Exception as e: |
30 logging.warning('Failed waiting for %s to die. %s', p.pid, e) | 30 logging.warning('Failed waiting for %s to die. %s', p.pid, e) |
31 | 31 |
32 | 32 |
33 def CleanupLeftoverProcesses(devices): | 33 def CleanupLeftoverProcesses(): |
34 """Clean up the test environment, restarting fresh adb and HTTP daemons. | 34 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" |
35 | |
36 Args: | |
37 devices: The devices to clean. | |
38 """ | |
39 _KillWebServers() | 35 _KillWebServers() |
40 device_utils.RestartServer() | 36 device_utils.RestartServer() |
41 | 37 |
42 def cleanup_device(d): | 38 def cleanup_device(d): |
43 d.RestartAdbd() | 39 d.RestartAdbd() |
44 try: | 40 try: |
45 d.EnableRoot() | 41 d.EnableRoot() |
46 except device_errors.CommandFailedError as e: | 42 except device_errors.CommandFailedError as e: |
47 logging.error(str(e)) | 43 logging.error(str(e)) |
48 d.WaitUntilFullyBooted() | 44 d.WaitUntilFullyBooted() |
49 | 45 |
50 device_utils.DeviceUtils.parallel(devices).pMap(cleanup_device) | 46 device_utils.DeviceUtils.parallel().pMap(cleanup_device) |
51 | 47 |
OLD | NEW |