Skip to content

Exception cleanup #59

@liamhuber

Description

@liamhuber

contextlib.ExitStack provides a with context onto which we can slap callbacks for when the context is exited. However, these all always fire when the context is exited.

Sometimes in pyiron_workflow, I have a series of operations that make progressive modifications to some state, but if I encounter an error I want to go back and revert whatever changes have been made so far before raising the error. Right now I manually handle these callbacks, but It seems to me like this is a special case of ExitStack, "ExceptionStack" maybe.

This can be pretty easily constructed as a custom context manager and I thought it might be a nice addition here.

Feeback from anyone/@pmrv?

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