OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # pylint: disable=W0212 | 5 # pylint: disable=W0212 |
6 | 6 |
7 import fcntl | 7 import fcntl |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import psutil | 10 import psutil |
11 | 11 |
12 from pylib import cmd_helper | 12 from pylib import cmd_helper |
13 from pylib import constants | 13 from pylib import constants |
14 from pylib import valgrind_tools | 14 from pylib import valgrind_tools |
| 15 from pylib.device import device_errors |
15 | 16 |
16 # TODO(jbudorick) Remove once telemetry gets switched over. | 17 # TODO(jbudorick) Remove once telemetry gets switched over. |
17 import pylib.android_commands | 18 import pylib.android_commands |
18 import pylib.device.device_utils | 19 import pylib.device.device_utils |
19 | 20 |
20 | 21 |
21 def _GetProcessStartTime(pid): | 22 def _GetProcessStartTime(pid): |
22 return psutil.Process(pid).create_time | 23 return psutil.Process(pid).create_time |
23 | 24 |
24 | 25 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 334 |
334 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), | 335 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), |
335 Forwarder._DEVICE_FORWARDER_PATH) | 336 Forwarder._DEVICE_FORWARDER_PATH) |
336 device.old_interface.GetAndroidToolStatusAndOutput( | 337 device.old_interface.GetAndroidToolStatusAndOutput( |
337 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 338 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) |
338 | 339 |
339 # TODO(pliard): Remove the following call to KillAllBlocking() when we are | 340 # TODO(pliard): Remove the following call to KillAllBlocking() when we are |
340 # sure that the old version of device_forwarder (not supporting | 341 # sure that the old version of device_forwarder (not supporting |
341 # 'kill-server') is not running on the bots anymore. | 342 # 'kill-server') is not running on the bots anymore. |
342 timeout_sec = 5 | 343 timeout_sec = 5 |
343 processes_killed = device.old_interface.KillAllBlocking( | 344 try: |
344 'device_forwarder', timeout_sec) | 345 device.KillAll( |
345 if not processes_killed: | 346 'device_forwarder', blocking=True, timeout=timeout_sec) |
| 347 except device_errors.CommandFailedError: |
346 pids = device.old_interface.ExtractPid('device_forwarder') | 348 pids = device.old_interface.ExtractPid('device_forwarder') |
347 if pids: | 349 if pids: |
348 raise Exception('Timed out while killing device_forwarder') | 350 raise |
OLD | NEW |