Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Unified Diff: devil/devil/utils/timeout_retry.py

Issue 3000973002: Make timeout_retry include the total timeout in the exception error (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | devil/devil/utils/watchdog_timer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/utils/timeout_retry.py
diff --git a/devil/devil/utils/timeout_retry.py b/devil/devil/utils/timeout_retry.py
index d2304629e9c00a66b114191e2bc5cbb34f52b94a..2327b6bf0ca46c93bbe7a185121eb09e39699dae 100644
--- a/devil/devil/utils/timeout_retry.py
+++ b/devil/devil/utils/timeout_retry.py
@@ -28,7 +28,7 @@ class TimeoutRetryThreadGroup(reraiser_thread.ReraiserThreadGroup):
def GetElapsedTime(self):
return self._watcher.GetElapsed()
- def GetRemainingTime(self, required=0, msg=None):
+ def GetRemainingTime(self, required=0, suffix=None):
"""Get the remaining time before the thread times out.
Useful to send as the |timeout| parameter of async IO operations.
@@ -48,11 +48,9 @@ class TimeoutRetryThreadGroup(reraiser_thread.ReraiserThreadGroup):
"""
remaining = self._watcher.GetRemaining()
if remaining is not None and remaining < required:
- if msg is None:
- msg = 'Timeout expired'
- if remaining > 0:
- msg += (', wait of %.1f secs required but only %.1f secs left'
- % (required, remaining))
+ msg = 'Timeout of %.1f secs expired' % self._watcher.GetTimeout()
+ if suffix:
+ msg += suffix
raise reraiser_thread.TimeoutError(msg)
return remaining
@@ -110,7 +108,7 @@ def WaitFor(condition, wait_period=5, max_tries=None):
if timeout_thread_group:
# pylint: disable=no-member
timeout_thread_group.GetRemainingTime(wait_period,
- msg='Timed out waiting for %r' % condition_name)
+ suffix=' waiting for condition %r' % condition_name)
time.sleep(wait_period)
return None
« no previous file with comments | « no previous file | devil/devil/utils/watchdog_timer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698