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

Side by Side Diff: build/android/devil/utils/timeout_retry.py

Issue 1315743004: [Android] Add a custom pylintrc for build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix appurify_sanitized import-errors Created 5 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 unified diff | Download patch
« no previous file with comments | « build/android/devil/utils/reset_usb.py ('k') | build/android/emma_coverage_stats.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """A utility to run functions with timeouts and retries.""" 5 """A utility to run functions with timeouts and retries."""
6 # pylint: disable=W0702 6 # pylint: disable=W0702
7 7
8 import logging 8 import logging
9 import threading 9 import threading
10 import time 10 import time
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 and the timeout expires. 106 and the timeout expires.
107 """ 107 """
108 condition_name = condition.__name__ 108 condition_name = condition.__name__
109 timeout_thread = CurrentTimeoutThread() 109 timeout_thread = CurrentTimeoutThread()
110 while max_tries is None or max_tries > 0: 110 while max_tries is None or max_tries > 0:
111 result = condition() 111 result = condition()
112 if max_tries is not None: 112 if max_tries is not None:
113 max_tries -= 1 113 max_tries -= 1
114 msg = ['condition', repr(condition_name), 'met' if result else 'not met'] 114 msg = ['condition', repr(condition_name), 'met' if result else 'not met']
115 if timeout_thread: 115 if timeout_thread:
116 # pylint: disable=no-member
116 msg.append('(%.1fs)' % timeout_thread.GetElapsedTime()) 117 msg.append('(%.1fs)' % timeout_thread.GetElapsedTime())
117 logging.info(' '.join(msg)) 118 logging.info(' '.join(msg))
118 if result: 119 if result:
119 return result 120 return result
120 if timeout_thread: 121 if timeout_thread:
122 # pylint: disable=no-member
121 timeout_thread.GetRemainingTime(wait_period, 123 timeout_thread.GetRemainingTime(wait_period,
122 msg='Timed out waiting for %r' % condition_name) 124 msg='Timed out waiting for %r' % condition_name)
123 time.sleep(wait_period) 125 time.sleep(wait_period)
124 return None 126 return None
125 127
126 128
127 def Run(func, timeout, retries, args=None, kwargs=None): 129 def Run(func, timeout, retries, args=None, kwargs=None):
128 """Runs the passed function in a separate thread with timeouts and retries. 130 """Runs the passed function in a separate thread with timeouts and retries.
129 131
130 Args: 132 Args:
(...skipping 27 matching lines...) Expand all
158 try: 160 try:
159 thread_group = reraiser_thread.ReraiserThreadGroup([child_thread]) 161 thread_group = reraiser_thread.ReraiserThreadGroup([child_thread])
160 thread_group.StartAll() 162 thread_group.StartAll()
161 thread_group.JoinAll(child_thread.GetWatcher()) 163 thread_group.JoinAll(child_thread.GetWatcher())
162 return ret[0] 164 return ret[0]
163 except: 165 except:
164 child_thread.LogTimeoutException() 166 child_thread.LogTimeoutException()
165 if num_try > retries: 167 if num_try > retries:
166 raise 168 raise
167 num_try += 1 169 num_try += 1
OLDNEW
« no previous file with comments | « build/android/devil/utils/reset_usb.py ('k') | build/android/emma_coverage_stats.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698