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

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: fix the parallelizer tests 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
« no previous file with comments | « build/android/pylib/utils/parallelizer_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..64196b26e879448884b9ca96d07adfac4a8d8e18 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 GetReturnValue(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 GetAllReturnValues(self, watcher=watchdog_timer.WatchdogTimer(None)):
+ """Get all return values, joining all threads if necessary.
+
+ 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.GetReturnValue() for t in self._threads]
+
« no previous file with comments | « build/android/pylib/utils/parallelizer_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698