Brain Docs

Reference

Python SDKInstallationHTTP clientWire clientSync vs async
txn_begintxn_committxn_abort
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Python SDKTransactionstxn_abort

txn_abort

Discard a transaction's writes without waiting for its timeout.

PURPOSE

Discard the transaction and everything in it. Call it from a finally so a thrown error does not leave the transaction open until its timeout elapses.

Handshake credentialstable
txn_abort(request: TxnAbortRequest) -> TxnAbortResponse

Parameters

ParameterTypeRequired
txn_idUUID bytesrequired

The transaction to discard.

Returns

FieldTypePresence
txn_idUUID bytesalways

Echoed back.

operations_discardedintegeralways

How many operations were thrown away.

Example

txn_id = new_id()
client.txn_begin(TxnBeginRequest(txn_id=txn_id, timeout_seconds=30))
try:
    write_everything(txn_id)
    res = client.txn_commit(TxnCommitRequest(txn_id=txn_id))
    print("applied", res.operations_applied)
except Exception:
    client.txn_abort(TxnAbortRequest(txn_id=txn_id))
    raise

HTTP has no transactions

The HTTP edge exposes no transaction routes. Each HTTP verb is its own unit. If several writes must land together, you need the wire client — see Wire client.

See also
txn_begintxn_commit

Was this page helpful?

txn_commit

Apply a transaction's writes atomically, and check that every write actually joined it.

put_llm_credential

Register or replace the namespace's provider key — verified with the provider before it is stored.

On this page

ParametersReturnsExample
Suggest an editOpen in Playground