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

Side by Side Diff: build/android/pylib/utils/reraiser_thread.py

Issue 358993003: [Android] Switch to DeviceUtils versions of file functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/pylib/uiautomator/test_package.py ('k') | build/android/pylib/valgrind_tools.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 """Thread and ThreadGroup that reraise exceptions on the main thread.""" 5 """Thread and ThreadGroup that reraise exceptions on the main thread."""
6 # pylint: disable=W0212 6 # pylint: disable=W0212
7 7
8 import logging 8 import logging
9 import sys 9 import sys
10 import threading 10 import threading
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 def GetReturnValue(self): 67 def GetReturnValue(self):
68 """Reraise exception if present, otherwise get the return value.""" 68 """Reraise exception if present, otherwise get the return value."""
69 self.ReraiseIfException() 69 self.ReraiseIfException()
70 return self._ret 70 return self._ret
71 71
72 #override 72 #override
73 def run(self): 73 def run(self):
74 """Overrides Thread.run() to add support for reraising exceptions.""" 74 """Overrides Thread.run() to add support for reraising exceptions."""
75 try: 75 try:
76 self._ret = self._func(*self._args, **self._kwargs) 76 self._ret = self._func(*self._args, **self._kwargs)
77 except: 77 except: # pylint: disable=W0702
78 self._exc_info = sys.exc_info() 78 self._exc_info = sys.exc_info()
79 raise
80 79
81 80
82 class ReraiserThreadGroup(object): 81 class ReraiserThreadGroup(object):
83 """A group of ReraiserThread objects.""" 82 """A group of ReraiserThread objects."""
84 83
85 def __init__(self, threads=None): 84 def __init__(self, threads=None):
86 """Initialize thread group. 85 """Initialize thread group.
87 86
88 Args: 87 Args:
89 threads: a list of ReraiserThread objects; defaults to empty. 88 threads: a list of ReraiserThread objects; defaults to empty.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 def GetAllReturnValues(self, watcher=watchdog_timer.WatchdogTimer(None)): 147 def GetAllReturnValues(self, watcher=watchdog_timer.WatchdogTimer(None)):
149 """Get all return values, joining all threads if necessary. 148 """Get all return values, joining all threads if necessary.
150 149
151 Args: 150 Args:
152 watcher: same as in |JoinAll|. Only used if threads are alive. 151 watcher: same as in |JoinAll|. Only used if threads are alive.
153 """ 152 """
154 if any([t.isAlive() for t in self._threads]): 153 if any([t.isAlive() for t in self._threads]):
155 self.JoinAll(watcher) 154 self.JoinAll(watcher)
156 return [t.GetReturnValue() for t in self._threads] 155 return [t.GetReturnValue() for t in self._threads]
157 156
OLDNEW
« no previous file with comments | « build/android/pylib/uiautomator/test_package.py ('k') | build/android/pylib/valgrind_tools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698