pyrseus.executors.nocatch.NoCatchExecutor¶
- class pyrseus.executors.nocatch.NoCatchExecutor[source]¶
Bases:
Executor- __init__()[source]¶
A simple serial
Executorthat evaluates tasks immediately upon submission, and does not capture task exceptions in their futures.Summary¶
Common Use Cases: for troubleshooting, as a fail-fast variant of the
InlineExecutor.Concurrency: This is a non-concurrent, serial-only executor. All tasks are immediately run in the same process and thread they were submitted in.
Exceptions: This executor has non-standard exception-handling semantics: no task exceptions are caught and captured in their futures. Exceptions are propagated out immediately.
Default max_workers: Not applicable.
Pickling: This executor does not perform any pickling.
Details¶
This is primarily useful for troubleshooting when one wants to enter a debugger as early and as easily as possible, at the cost of non-standard error handling.
Consider the following function that raises an exception:
>>> def raises(): ... raise RuntimeError("An exception was raised by our function.")
With this class, the exception is propagated out immediately at
submittime.>>> with NoCatchExecutor() as exe: ... exe.submit(raises) # <--- NOTE: no fut.result() needed Traceback (most recent call last): ... RuntimeError: An exception was raised by our function.
See Pyrseus’ Executor Classes for a list of related executors.
Methods
__init__()A simple serial
Executorthat evaluates tasks immediately upon submission, and does not capture task exceptions in their futures.map(fn, *iterables[, timeout, chunksize])Returns an iterator equivalent to map(fn, iter).
shutdown(*args, **kwargs)As a minor improvement on the base class' method, this override disallows submissions after a shutdown has been started.
submit(fcn, /, *args, **kwargs)Immediately evaluates
fcn(*args, **kwargs)and embeds the result in aFuture.- __enter__()¶
- __exit__(exc_type, exc_val, exc_tb)¶
- map(fn, *iterables, timeout=None, chunksize=1)¶
Returns an iterator equivalent to map(fn, iter).
- Parameters:
fn – A callable that will take as many arguments as there are passed iterables.
timeout – The maximum number of seconds to wait. If None, then there is no limit on the wait time.
chunksize – The size of the chunks the iterable will be broken into before being passed to a child process. This argument is only used by ProcessPoolExecutor; it is ignored by ThreadPoolExecutor.
- Returns:
map(func, *iterables) but the calls may be evaluated out-of-order.
- Return type:
An iterator equivalent to
- Raises:
TimeoutError – If the entire result iterator could not be generated before the given timeout.