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

Side by Side Diff: build/android/devil/utils/reraiser_thread.py

Issue 1415533007: [Android] Add sharding for AMP instrumentation tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change to uirobot SetupTestShards. Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 Returns: 207 Returns:
208 The current thread group, otherwise None. 208 The current thread group, otherwise None.
209 """ 209 """
210 current_thread = threading.current_thread() 210 current_thread = threading.current_thread()
211 if isinstance(current_thread, ReraiserThread): 211 if isinstance(current_thread, ReraiserThread):
212 return current_thread._thread_group # pylint: disable=no-member 212 return current_thread._thread_group # pylint: disable=no-member
213 return None 213 return None
214 214
215 215
216 def RunAsync(funcs, watcher=None): 216 def RunAsync(funcs, args=None, kwargs=None, watcher=None, names=None):
217 """Executes the given functions in parallel and returns their results. 217 """Executes the given functions in parallel and returns their results.
218 218
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 args: List of list of args to be passed to the corresponding func.
222 kwargs: List of dicts of kwargs to be passed to the corresponding func.
221 watcher: Watchdog object providing timeout, by default waits forever. 223 watcher: Watchdog object providing timeout, by default waits forever.
224 names: List of names for the threads.
222 225
223 Returns: 226 Returns:
224 A list of return values in the order of the given functions. 227 A list of return values in the order of the given functions.
225 """ 228 """
226 thread_group = ReraiserThreadGroup(ReraiserThread(f) for f in funcs) 229 args = args or [None]*len(funcs)
jbudorick 2015/12/01 04:07:13 where's the linter when I need it... spaces around
230 kwargs = kwargs or [None]*len(funcs)
231 names = names or [None]*len(funcs)
232
233 thread_group = ReraiserThreadGroup(
234 ReraiserThread(f, args=a, kwargs=k, name=n)
jbudorick 2015/12/01 04:07:13 Adding these probably means you're abusing RunAsyn
235 for (f, a, k, n) in zip(funcs, args, kwargs, names))
227 thread_group.StartAll(will_block=True) 236 thread_group.StartAll(will_block=True)
228 return thread_group.GetAllReturnValues(watcher=watcher) 237 return thread_group.GetAllReturnValues(watcher=watcher)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698