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

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

Issue 1314913009: [Android] Move some pylib modules into devil/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """ Wrapper that allows method execution in parallel. 5 """ Wrapper that allows method execution in parallel.
6 6
7 This class wraps a list of objects of the same type, emulates their 7 This class wraps a list of objects of the same type, emulates their
8 interface, and executes any functions called on the objects in parallel 8 interface, and executes any functions called on the objects in parallel
9 in ReraiserThreads. 9 in ReraiserThreads.
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 DoesSomethingWithFoo(Parallelizer(list_of_foos)) 48 DoesSomethingWithFoo(Parallelizer(list_of_foos))
49 49
50 Note that this class spins up a thread for each object. Using this class 50 Note that this class spins up a thread for each object. Using this class
51 to parallelize operations that are already fast will incur a net performance 51 to parallelize operations that are already fast will incur a net performance
52 penalty. 52 penalty.
53 53
54 """ 54 """
55 # pylint: disable=protected-access 55 # pylint: disable=protected-access
56 56
57 from pylib.utils import reraiser_thread 57 from devil.utils import reraiser_thread
58 from pylib.utils import watchdog_timer 58 from devil.utils import watchdog_timer
59 59
60 _DEFAULT_TIMEOUT = 30 60 _DEFAULT_TIMEOUT = 30
61 _DEFAULT_RETRIES = 3 61 _DEFAULT_RETRIES = 3
62 62
63 63
64 class Parallelizer(object): 64 class Parallelizer(object):
65 """Allows parallel execution of method calls across a group of objects.""" 65 """Allows parallel execution of method calls across a group of objects."""
66 66
67 def __init__(self, objs): 67 def __init__(self, objs):
68 assert (objs is not None and len(objs) > 0), ( 68 assert (objs is not None and len(objs) > 0), (
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 args: The positional args to pass to f. 233 args: The positional args to pass to f.
234 kwargs: The keyword args to pass to f. 234 kwargs: The keyword args to pass to f.
235 Returns: 235 Returns:
236 A Parallelizer wrapping the ReraiserThreadGroup running the map in 236 A Parallelizer wrapping the ReraiserThreadGroup running the map in
237 parallel. 237 parallel.
238 """ 238 """
239 r = super(SyncParallelizer, self).pMap(f, *args, **kwargs) 239 r = super(SyncParallelizer, self).pMap(f, *args, **kwargs)
240 r.pFinish(None) 240 r.pFinish(None)
241 return r 241 return r
242 242
OLDNEW
« no previous file with comments | « build/android/devil/utils/mock_calls_test.py ('k') | build/android/devil/utils/parallelizer_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698