| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS 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 time | 5 import time |
| 6 from autotest_lib.client.common_lib import error | 6 from autotest_lib.client.common_lib import error |
| 7 | 7 |
| 8 | 8 |
| 9 class TimeoutError(error.TestError): | 9 class TimeoutError(error.TestError): |
| 10 """Error raised when we time out when waiting on a condition.""" | 10 """Error raised when we time out when waiting on a condition.""" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if condition(): | 28 if condition(): |
| 29 return | 29 return |
| 30 if time.time() + sleep_interval - start_time > timeout: | 30 if time.time() + sleep_interval - start_time > timeout: |
| 31 if exception: | 31 if exception: |
| 32 raise exception | 32 raise exception |
| 33 | 33 |
| 34 if desc: | 34 if desc: |
| 35 desc = 'Timed out waiting for condition: %s' % desc | 35 desc = 'Timed out waiting for condition: %s' % desc |
| 36 else: | 36 else: |
| 37 desc = 'Timed out waiting for unnamed condition' | 37 desc = 'Timed out waiting for unnamed condition' |
| 38 raise error.TestError(desc) | 38 raise TimeoutError, desc |
| 39 | 39 |
| 40 time.sleep(sleep_interval) | 40 time.sleep(sleep_interval) |
| OLD | NEW |