Python 3.9 is now generally available.

google.appengine.api.datastore.IsInTransaction

Determine whether already running in transaction.

True if already running in transaction, else False.