MCPcopy Create free account
hub / github.com/mongodb/motor / commit_with_retry

Method commit_with_retry

test/asyncio_tests/test_examples.py:1042–1056  ·  view source on GitHub ↗
(session)

Source from the content-addressed store, hash-verified

1040
1041 # Start Transactions Retry Example 2
1042 async def commit_with_retry(session):
1043 while True:
1044 try:
1045 # Commit uses write concern set at transaction start.
1046 await session.commit_transaction()
1047 print("Transaction committed.")
1048 break
1049 except (ConnectionFailure, OperationFailure) as exc:
1050 # Can retry commit
1051 if exc.has_error_label("UnknownTransactionCommitResult"):
1052 print("UnknownTransactionCommitResult, retrying commit operation ...")
1053 continue
1054 else:
1055 print("Error during commit ...")
1056 raise
1057
1058 # End Transactions Retry Example 2
1059

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected