Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 906 Bytes

exception_processing.md

File metadata and controls

17 lines (11 loc) · 906 Bytes

Exception processing

By default, both mtasklite and PQDM ignore exceptions: When a task terminates due to an exception the exception is returned instead of a return value.

You can check if an exception happened using a convenience wrapper:

from mtasklite import is_exception

if is_exception(ret_val):
   do_something()

It is possible to change the behavior through the argument exception_behavior. Two additional options are supported:

ExceptionBehaviour.IMMEDIATE: Once a worker raises an exception, we stop reading from the input iterable and wait for workers that have already read from the input iterable. Then we raise the exception in the main process/thread.

  1. ExceptionBehaviour.DEFERRED: All exceptions are collected and passed to the main process/thread. When all tasks are processed, we raise a single exception that "contains" all exceptions generated by workers.