Chromium Code Reviews| 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 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 Args: | 219 Args: |
| 220 funcs: List of functions to perform on their own threads. | 220 funcs: List of functions to perform on their own threads. |
| 221 watcher: Watchdog object providing timeout, by default waits forever. | 221 watcher: Watchdog object providing timeout, by default waits forever. |
| 222 | 222 |
| 223 Returns: | 223 Returns: |
| 224 A list of return values in the order of the given functions. | 224 A list of return values in the order of the given functions. |
| 225 """ | 225 """ |
| 226 thread_group = ReraiserThreadGroup(ReraiserThread(f) for f in funcs) | 226 thread_group = ReraiserThreadGroup(ReraiserThread(f) for f in funcs) |
| 227 thread_group.StartAll(will_block=True) | 227 thread_group.StartAll(will_block=True) |
| 228 return thread_group.GetAllReturnValues(watcher=watcher) | 228 return thread_group.GetAllReturnValues(watcher=watcher) |
| 229 | |
| 230 def RunThreadsSync(threads): | |
|
jbudorick
2015/11/17 18:04:46
There's no reason why both this and RunAsync shoul
mikecase (-- gone --)
2015/11/19 01:35:37
Added support to RunAsync to pass args and kwargs
| |
| 231 """Runs the given threads in parallel and blocks until all threads finish. | |
| 232 | |
| 233 Args: | |
| 234 threads: List of reraiser_thread objects. | |
| 235 """ | |
| 236 workers = ReraiserThreadGroup(threads) | |
| 237 workers.StartAll() | |
| 238 workers.JoinAll() | |
| OLD | NEW |