Managing transactions
Transactions in Tuxedo can be started by using the tpbegin
function call with the transaction timeout in seconds as the parameter. The transaction must be either committed by using the tpcommit
function or aborted by using the tpabort
function.
Tip
I recommend creating a Python Context Manager for transactions to ensure the transaction is always completed by committing or aborting it.
Here is an example of how to create a transaction and call service within a transaction:
import tuxedo as t t.tpbegin(3) t.tpcall("PING", {}) t.tpcommit()
ULOG
will show that the service was called in a transaction although we did nothing special for the service invocation. Transactions in Tuxedo are infectious: once the code executes in a transaction, all service calls are performed in the same transaction. How can you know if the code executes in a transaction? One way of knowing is to inspect the flags
service that it receives in parameters as we did in...