Chromium Code Reviews| 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 2964bef1e8265e3931e2cdda15f626d8f131cc77..f465b43bdc641619f1606ba55f210e8f81835aec 100644 |
| --- a/build/android/pylib/utils/reraiser_thread.py |
| +++ b/build/android/pylib/utils/reraiser_thread.py |
| @@ -58,6 +58,7 @@ class ReraiserThread(threading.Thread): |
| self._kwargs = kwargs |
| self._ret = None |
| self._exc_info = None |
| + self._stopped = False |
| def ReraiseIfException(self): |
| """Reraise exception if an exception was raised in the thread.""" |
| @@ -69,6 +70,13 @@ class ReraiserThread(threading.Thread): |
| self.ReraiseIfException() |
| return self._ret |
| + def StopThread(self): |
|
jbudorick
2014/10/24 17:30:51
I don't think we want to provide this in reraiser_
perezju
2014/10/27 11:07:07
Looking around, e.g. http://stackoverflow.com/ques
jbudorick
2014/10/27 19:15:36
I'm not sure this is better than what we do now. I
perezju
2014/10/28 14:31:17
Just for fun, trying to reboot with a very low tim
|
| + """Request this thread to stop.""" |
| + self._stopped = True |
| + |
| + def Stopped(self): |
| + return self._stopped |
| + |
| #override |
| def run(self): |
| """Overrides Thread.run() to add support for reraising exceptions.""" |
| @@ -104,7 +112,7 @@ class ReraiserThreadGroup(object): |
| for thread in self._threads: |
| thread.start() |
| - def _JoinAll(self, watcher=watchdog_timer.WatchdogTimer(None)): |
| + def _JoinAll(self, watcher): |
| """Join all threads without stack dumps. |
| Reraises exceptions raised by the child threads and supports breaking |
| @@ -127,7 +135,7 @@ class ReraiserThreadGroup(object): |
| for thread in self._threads: |
| thread.ReraiseIfException() |
| - def JoinAll(self, watcher=watchdog_timer.WatchdogTimer(None)): |
| + def JoinAll(self, watcher=None): |
| """Join all threads. |
| Reraises exceptions raised by the child threads and supports breaking |
| @@ -137,11 +145,14 @@ class ReraiserThreadGroup(object): |
| Args: |
| watcher: Watchdog object providing timeout, by default waits forever. |
| """ |
| + if watcher is None: |
| + watcher=watchdog_timer.WatchdogTimer(None) |
|
jbudorick
2014/10/24 17:30:52
nice catch.
nit: spaces around =
|
| try: |
| self._JoinAll(watcher) |
| except TimeoutError: |
| for thread in (t for t in self._threads if t.isAlive()): |
| LogThreadStack(thread) |
| + thread.StopThread() |
| raise |
| def GetAllReturnValues(self, watcher=watchdog_timer.WatchdogTimer(None)): |