@contextlib.contextmanager
def remove_path_on_error(path):
    try:
        yield
    except Exception:
        with excutils.save_and_reraise_exception():
            delete_if_exists(path)
Protect code that wants to operate on PATH atomically.
dataset/ETHPy150Open Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/openstack_dashboard/openstack/common/fileutils.py/remove_path_on_error