ceph.parallel module
- class ceph.parallel.ExceptionHolder(exc_info)
Bases:
object
- ceph.parallel.capture_traceback(func, *args, **kwargs)
Utility function to capture tracebacks of any exception func raises.
- class ceph.parallel.parallel
Bases:
objectThis class is a context manager for running functions in parallel.
You add functions to be run with the spawn method:
with parallel() as p: for foo in bar: p.spawn(quux, foo, baz=True)
You can iterate over the results (which are in arbitrary order):
with parallel() as p: for foo in bar: p.spawn(quux, foo, baz=True) for result in p: print result
If one of the spawned functions throws an exception, it will be thrown when iterating over the results, or when the with block ends.
At the end of the with block, the main thread waits until all spawned functions have completed, or, if one exited with an exception, kills the rest and raises the exception.
- spawn(func, *args, **kwargs)
- ceph.parallel.resurrect_traceback(exc)