Python 3.9 is now generally available.

google.appengine.api.datastore.RunInTransaction

Runs a function inside a datastore transaction.

Runs the user-provided function inside transaction, retries default number of times.

Args: function: a function to be run inside the transaction on all remaining arguments *args: positional arguments for function. **kwargs: keyword arguments for function.

the function's return value, if any

TransactionFailedError, if the transaction could not be committed.