project.transaction
Begin, commit, cancel, and renew project transactions.
5 functions / 1 types
Index
| Function | Description |
|---|---|
| begin | Opens a transaction and returns its id. An expired lease discards its writes. Call RenewLease before expiry to keep the transaction open. |
| cancel | Ends the transaction matching id as canceled, discarding its writes. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it. |
| commit | Ends the transaction matching id as committed. Errors when no transaction with that id is open, or when a concurrent Commit or Cancel already finalized it. |
| force_cancel | Cancels the open transaction without its id. This can cancel another caller’s transaction. Errors when no transaction is open. Prefer Cancel when the id is known. |
| renew_lease | Extends an unexpired transaction by its original lease duration. |
| Type | Description |
|---|---|
| TransactionMode | Policy for operations submitted while a transaction is open. |
begin
def begin(
*,
mode: types.project.transaction.TransactionMode,
lease_seconds: float | None = None,
_transaction_id: str | None = None
) -> strOpens a transaction and returns its id. An expired lease discards its writes.
Call RenewLease before expiry to keep the transaction open.
Returns str.
mode : TransactionMode
Whether untagged operations are absorbed by this transaction.
lease_seconds optional : float | None
Lease duration in seconds. Defaults to 60. Must be finite and between 0.001 and 86400. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
cancel
def cancel(*, id: str, _transaction_id: str | None = None) -> NoneEnds the transaction matching id as canceled, discarding its writes. Errors when no
transaction with that id is open, or when a concurrent Commit or Cancel already finalized it.
Returns None.
id : str
The transaction to end (hyphenated UUID string).
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
commit
def commit(*, id: str, _transaction_id: str | None = None) -> NoneEnds the transaction matching id as committed. Errors when no transaction with that id is
open, or when a concurrent Commit or Cancel already finalized it.
Returns None.
id : str
The transaction to end (hyphenated UUID string).
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
force_cancel
def force_cancel(*, _transaction_id: str | None = None) -> NoneCancels the open transaction without its id. This can cancel another caller’s transaction.
Errors when no transaction is open. Prefer Cancel when the id is known.
Returns None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
renew_lease
def renew_lease(*, id: str, _transaction_id: str | None = None) -> NoneExtends an unexpired transaction by its original lease duration.
Returns None.
id : str
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
TransactionMode
Enum
class TransactionMode(IntEnum)Policy for operations submitted while a transaction is open.
Shared (default) includes every operation. Private accepts only operations tagged with
this transaction’s ID and rejects others with StatementError.TransactionNotAdmitted.
Values: SHARED = 0 PRIVATE = 1
SHARED = 0
PRIVATE = 1