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

Unified Diff: build/android/pylib/utils/reraiser_thread.py

Issue 290573004: [Android] Support generic parallel execution across devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
Index: build/android/pylib/utils/reraiser_thread.py
diff --git a/build/android/pylib/utils/reraiser_thread.py b/build/android/pylib/utils/reraiser_thread.py
index eed72c173ead636d8397a174ef3a92757f43e596..32489f57b623f8717ebf7b95ce73a87a85d8a9da 100644
--- a/build/android/pylib/utils/reraiser_thread.py
+++ b/build/android/pylib/utils/reraiser_thread.py
@@ -56,6 +56,7 @@ class ReraiserThread(threading.Thread):
self._func = func
self._args = args
self._kwargs = kwargs
+ self._ret = None
self._exc_info = None
def ReraiseIfException(self):
@@ -63,11 +64,16 @@ class ReraiserThread(threading.Thread):
if self._exc_info:
raise self._exc_info[0], self._exc_info[1], self._exc_info[2]
+ def Get(self):
+ """Reraise exception if present, otherwise get the return value."""
+ self.ReraiseIfException()
+ return self._ret
+
#override
def run(self):
"""Overrides Thread.run() to add support for reraising exceptions."""
try:
- self._func(*self._args, **self._kwargs)
+ self._ret = self._func(*self._args, **self._kwargs)
except:
self._exc_info = sys.exc_info()
raise
@@ -138,3 +144,14 @@ class ReraiserThreadGroup(object):
for thread in (t for t in self._threads if t.isAlive()):
LogThreadStack(thread)
raise
+
+ def Get(self, watcher=watchdog_timer.WatchdogTimer(None)):
+ """Get all results, joining all threads if necessary.
craigdh 2014/05/16 21:59:35 Inconsistent use of results/return value in these
jbudorick 2014/05/21 16:42:48 Done.
+
+ Args:
+ watcher: same as in |JoinAll|. Only used if threads are alive.
+ """
+ if any([t.isAlive() for t in self._threads]):
+ self.JoinAll(watcher)
+ return [t.Get() for t in self._threads]
+

Powered by Google App Engine
This is Rietveld 408576698