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

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

Issue 1314913009: [Android] Move some pylib modules into devil/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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
11 import traceback 11 import traceback
12 12
13 from pylib.utils import reraiser_thread 13 from devil.utils import reraiser_thread
14 from pylib.utils import watchdog_timer 14 from devil.utils import watchdog_timer
15 15
16 16
17 class TimeoutRetryThread(reraiser_thread.ReraiserThread): 17 class TimeoutRetryThread(reraiser_thread.ReraiserThread):
18 def __init__(self, func, timeout, name): 18 def __init__(self, func, timeout, name):
19 super(TimeoutRetryThread, self).__init__(func, name=name) 19 super(TimeoutRetryThread, self).__init__(func, name=name)
20 self._watcher = watchdog_timer.WatchdogTimer(timeout) 20 self._watcher = watchdog_timer.WatchdogTimer(timeout)
21 self._expired = False 21 self._expired = False
22 22
23 def GetWatcher(self): 23 def GetWatcher(self):
24 """Returns the watchdog keeping track of this thread's time.""" 24 """Returns the watchdog keeping track of this thread's time."""
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 try: 158 try:
159 thread_group = reraiser_thread.ReraiserThreadGroup([child_thread]) 159 thread_group = reraiser_thread.ReraiserThreadGroup([child_thread])
160 thread_group.StartAll() 160 thread_group.StartAll()
161 thread_group.JoinAll(child_thread.GetWatcher()) 161 thread_group.JoinAll(child_thread.GetWatcher())
162 return ret[0] 162 return ret[0]
163 except: 163 except:
164 child_thread.LogTimeoutException() 164 child_thread.LogTimeoutException()
165 if num_try > retries: 165 if num_try > retries:
166 raise 166 raise
167 num_try += 1 167 num_try += 1
OLDNEW
« no previous file with comments | « build/android/devil/utils/run_tests_helper.py ('k') | build/android/devil/utils/watchdog_timer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698