Skip to content

Add utility function to classify exceptions as failing the workflow vs failing the task #589

@dandavison

Description

@dandavison

See the waiting_for_handlers and waiting_for_handlers_and_compensation Python samples added in temporalio/samples-python#144, which feature a utility function like this:

def is_workflow_exit_exception(e: BaseException) -> bool:
    """
    True if the exception is of a type that will cause the workflow to exit.

    This is as opposed to exceptions that cause a workflow task failure, which
    are retried automatically by Temporal.
    """
    # 👉 If you have set additional failure_exception_types you should also
    # check for these here.
    return isinstance(e, (asyncio.CancelledError, exceptions.FailureError))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions