DatastoreTransaction#

class lsst.daf.butler.datastore.DatastoreTransaction(parent: DatastoreTransaction | None = None)#

Bases: object

Keeps a log of Datastore activity and allow rollback.

Parameters#

parentDatastoreTransaction, optional

The parent transaction (if any).

Notes#

This transaction object must be thread safe.

Methods Summary

commit()

Commit this transaction.

registerUndo(name, undoFunc, *args, **kwargs)

Register event with undo function.

rollback()

Roll back all events in this transaction.

undoWith(name, undoFunc, *args, **kwargs)

Register undo function if nested operation succeeds.

Methods Documentation

commit() None#

Commit this transaction.

registerUndo(name: str, undoFunc: Callable, *args: Any, **kwargs: Any) None#

Register event with undo function.

Parameters#

namestr

Name of the event.

undoFuncCallable

Function to undo this event.

*argstuple

Positional arguments to undoFunc.

**kwargs

Keyword arguments to undoFunc.

rollback() None#

Roll back all events in this transaction.

undoWith(name: str, undoFunc: Callable, *args: Any, **kwargs: Any) Iterator[None]#

Register undo function if nested operation succeeds.

Calls registerUndo.

This can be used to wrap individual undo-able statements within a DatastoreTransaction block. Multiple statements that can fail separately should not be part of the same undoWith block.

All arguments are forwarded directly to registerUndo.

Parameters#

namestr

The name to associate with this event.

undoFuncCallable

Function to undo this event.

*argstuple

Positional arguments for undoFunc.

**kwargstyping.Any

Keyword arguments for undoFunc.