Chromium Code Reviews| Index: build/android/pylib/device/adb_wrapper.py |
| diff --git a/build/android/pylib/device/adb_wrapper.py b/build/android/pylib/device/adb_wrapper.py |
| index f6ac660c276176c5bd75ded89fac57f63cf70243..6978e15d51a0e219a7fdb6f6594767e3cabe114c 100644 |
| --- a/build/android/pylib/device/adb_wrapper.py |
| +++ b/build/android/pylib/device/adb_wrapper.py |
| @@ -10,10 +10,13 @@ should be delegated to a higher level (ex. DeviceUtils). |
| import errno |
| import os |
| +import threading |
| +import time |
| from pylib import cmd_helper |
| from pylib.device import decorators |
| from pylib.device import device_errors |
| +from pylib.utils import timeout_retry |
| _DEFAULT_TIMEOUT = 30 |
| @@ -44,15 +47,34 @@ class AdbWrapper(object): |
| """ |
| self._device_serial = str(device_serial) |
| + @classmethod |
| + def Wait(cls, secs): |
| + """Wait for the specified ammount of seconds. |
| + |
| + A drop-in replacement for time.sleep, which just waits for a number of |
| + seconds. After the wait is over, however, the method checks to see whether |
| + we're running under a timed-out thread and raises an exception if needed. |
| + |
| + Args: |
| + secs: the number of seconds to sleep |
| + """ |
| + time.sleep(secs) |
| + current_thread = threading.current_thread() |
| + if isinstance(current_thread, timeout_retry.TimeoutRetryThread): |
| + current_thread.CheckTimeout() |
| + |
| # pylint: disable=W0613 |
| @classmethod |
| @decorators.WithTimeoutAndRetries |
| def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): |
| cmd = ['adb'] + arg_list |
| - exit_code, output = cmd_helper.GetCmdStatusAndOutput(cmd) |
| + try: |
| + exit_code, output = cmd_helper.GetCmdStatusAndOutput(cmd) |
| + finally: |
| + threading.current_thread().CheckTimeout() |
|
perezju
2014/10/28 14:31:18
doing the check here at least we: (1) make sure th
|
| if exit_code != 0: |
| raise device_errors.AdbCommandFailedError( |
| - cmd, 'returned non-zero exit code %s, output: %s' % |
| + cmd, 'returned non-zero exit code %d and output %r' % |
| (exit_code, output)) |
| # This catches some errors, including when the device drops offline; |
| # unfortunately adb is very inconsistent with error reporting so many |