OLD | NEW |
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 |
11 import traceback | 11 import traceback |
12 | 12 |
13 from pylib.utils import watchdog_timer | 13 from devil.utils import watchdog_timer |
14 | 14 |
15 | 15 |
16 class TimeoutError(Exception): | 16 class TimeoutError(Exception): |
17 """Module-specific timeout exception.""" | 17 """Module-specific timeout exception.""" |
18 pass | 18 pass |
19 | 19 |
20 | 20 |
21 def LogThreadStack(thread): | 21 def LogThreadStack(thread): |
22 """Log the stack for the given thread. | 22 """Log the stack for the given thread. |
23 | 23 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 def GetAllReturnValues(self, watcher=None): | 149 def GetAllReturnValues(self, watcher=None): |
150 """Get all return values, joining all threads if necessary. | 150 """Get all return values, joining all threads if necessary. |
151 | 151 |
152 Args: | 152 Args: |
153 watcher: same as in |JoinAll|. Only used if threads are alive. | 153 watcher: same as in |JoinAll|. Only used if threads are alive. |
154 """ | 154 """ |
155 if any([t.isAlive() for t in self._threads]): | 155 if any([t.isAlive() for t in self._threads]): |
156 self.JoinAll(watcher) | 156 self.JoinAll(watcher) |
157 return [t.GetReturnValue() for t in self._threads] | 157 return [t.GetReturnValue() for t in self._threads] |
158 | 158 |
OLD | NEW |