| Index: devil/devil/utils/parallelizer.py
|
| diff --git a/devil/devil/utils/parallelizer.py b/devil/devil/utils/parallelizer.py
|
| index 35995251c879b130e32f034f0238d4335315c3c6..678066c75077b982ca5ef854c8583188faae2b51 100644
|
| --- a/devil/devil/utils/parallelizer.py
|
| +++ b/devil/devil/utils/parallelizer.py
|
| @@ -118,7 +118,7 @@ class Parallelizer(object):
|
| o, args=args, kwargs=kwargs,
|
| name='%s.%s' % (str(d), o.__name__))
|
| for d, o in zip(self._orig_objs, self._objs)])
|
| - r._objs.StartAll() # pylint: disable=W0212
|
| + r._objs.StartAll()
|
| return r
|
|
|
| def pFinish(self, timeout):
|
| @@ -174,7 +174,7 @@ class Parallelizer(object):
|
| f, args=tuple([o] + list(args)), kwargs=kwargs,
|
| name='%s(%s)' % (f.__name__, d))
|
| for d, o in zip(self._orig_objs, self._objs)])
|
| - r._objs.StartAll() # pylint: disable=W0212
|
| + r._objs.StartAll()
|
| return r
|
|
|
| def _assertNoShadow(self, attr_name):
|
| @@ -200,6 +200,33 @@ class Parallelizer(object):
|
| class SyncParallelizer(Parallelizer):
|
| """A Parallelizer that blocks on function calls."""
|
|
|
| + def __enter__(self):
|
| + """Emulate entering the context of |self|.
|
| +
|
| + Note that this call is synchronous.
|
| +
|
| + Returns:
|
| + A Parallelizer emulating the value returned from entering into the
|
| + context of |self|.
|
| + """
|
| + r = type(self)(self._orig_objs)
|
| + r._objs = [o.__enter__ for o in r._objs]
|
| + return r.__call__()
|
| +
|
| + def __exit__(self, exc_type, exc_val, exc_tb):
|
| + """Emulate exiting the context of |self|.
|
| +
|
| + Note that this call is synchronous.
|
| +
|
| + Args:
|
| + exc_type: the exception type.
|
| + exc_val: the exception value.
|
| + exc_tb: the exception traceback.
|
| + """
|
| + r = type(self)(self._orig_objs)
|
| + r._objs = [o.__exit__ for o in r._objs]
|
| + r.__call__(exc_type, exc_val, exc_tb)
|
| +
|
| # override
|
| def __call__(self, *args, **kwargs):
|
| """Emulate calling |self| with |args| and |kwargs|.
|
|
|