| OLD | NEW | 
|---|
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 175     r = type(self)(self._orig_objs) | 175     r = type(self)(self._orig_objs) | 
| 176     r._objs = reraiser_thread.ReraiserThreadGroup( | 176     r._objs = reraiser_thread.ReraiserThreadGroup( | 
| 177         [reraiser_thread.ReraiserThread( | 177         [reraiser_thread.ReraiserThread( | 
| 178             f, args=tuple([o] + list(args)), kwargs=kwargs, | 178             f, args=tuple([o] + list(args)), kwargs=kwargs, | 
| 179             name='%s(%s)' % (f.__name__, d)) | 179             name='%s(%s)' % (f.__name__, d)) | 
| 180          for d, o in zip(self._orig_objs, self._objs)]) | 180          for d, o in zip(self._orig_objs, self._objs)]) | 
| 181     r._objs.StartAll() # pylint: disable=W0212 | 181     r._objs.StartAll() # pylint: disable=W0212 | 
| 182     return r | 182     return r | 
| 183 | 183 | 
| 184   def _assertNoShadow(self, attr_name): | 184   def _assertNoShadow(self, attr_name): | 
| 185     """Ensures that |attr_name| isn't shadowing part of the wrapped obejcts. | 185     """Ensures that |attr_name| isn't shadowing part of the wrapped objects. | 
| 186 | 186 | 
| 187     If the wrapped objects _do_ have an |attr_name| attribute, it will be | 187     If the wrapped objects _do_ have an |attr_name| attribute, it will be | 
| 188     inaccessible to clients. | 188     inaccessible to clients. | 
| 189 | 189 | 
| 190     Args: | 190     Args: | 
| 191       attr_name: The attribute to check. | 191       attr_name: The attribute to check. | 
| 192     Raises: | 192     Raises: | 
| 193       AssertionError if the wrapped objects have an attribute named 'attr_name' | 193       AssertionError if the wrapped objects have an attribute named 'attr_name' | 
| 194       or '_assertNoShadow'. | 194       or '_assertNoShadow'. | 
| 195     """ | 195     """ | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 232       f: The function to call. | 232       f: The function to call. | 
| 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 |  | 
| OLD | NEW | 
|---|