Chromium Code Reviews| Index: build/android/pylib/device/device_utils.py |
| diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py |
| index c8a5c3a48124107fe9142489c6cf999e4d143eb4..873daaa4bd42af251012744833b1dd8da1e27db9 100644 |
| --- a/build/android/pylib/device/device_utils.py |
| +++ b/build/android/pylib/device/device_utils.py |
| @@ -8,6 +8,7 @@ Provides a variety of device interactions based on adb. |
| Eventually, this will be based on adb_wrapper. |
| """ |
| +import multiprocessing |
| import pylib.android_commands |
| from pylib.device import adb_wrapper |
| @@ -16,6 +17,33 @@ def GetAVDs(): |
| return pylib.android_commands.GetAVDs() |
| +# multiprocessing map_async requires a top-level function for pickle library. |
| +def RebootDeviceSafe(device): |
| + """Reboot a device, wait for it to start, and squelch timeout exceptions.""" |
| + try: |
| + DeviceUtils(device).old_interface.Reboot(True) |
| + except Exception as e: |
|
dnj
2014/05/08 15:18:16
The original one explicitly catches DeviceUnrespon
navabi
2014/05/08 19:10:52
Done.
|
| + return e |
| + |
| + |
| +def RebootDevices(): |
| + """Reboot all attached and online devices.""" |
| + devices = pylib.android_commands.GetAttachedDevices() |
| + print 'Rebooting: %s' % devices |
| + if devices: |
| + pool = multiprocessing.Pool(len(devices)) |
| + results = pool.map_async(RebootDeviceSafe, devices).get(99999) |
| + |
| + for device, result in zip(devices, results): |
| + if result: |
| + print '%s failed to startup.' % device |
| + |
| + if any(results): |
| + print 'RebootDevices() Warning: %s' % results |
| + else: |
| + print 'Reboots complete.' |
| + |
| + |
| class DeviceUtils(object): |
| def __init__(self, device): |