Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pymongo/asynchronous/client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ async def callback(session, custom_arg, custom_kwarg=None):
``with_transaction`` starts a new transaction and re-executes
the ``callback``.

The ``callback`` MUST NOT silently handle command errors
without allowing such errors to propagate. Command errors may abort the
transaction on the server, and an attempt to commit the transaction will
be rejected with a ``NoSuchTransaction`` error. For more information see
the `transactions specification`_.

When :meth:`~AsyncClientSession.commit_transaction` raises an exception with
the ``"UnknownTransactionCommitResult"`` error label,
``with_transaction`` retries the commit until the result of the
Expand Down Expand Up @@ -689,6 +695,9 @@ async def callback(session, custom_arg, custom_kwarg=None):
:return: The return value of the ``callback``.

.. versionadded:: 3.9

.. _tranactions specification:
https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md#handling-errors-inside-the-callback
"""
start_time = time.monotonic()
while True:
Expand Down
9 changes: 9 additions & 0 deletions pymongo/synchronous/client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,12 @@ def callback(session, custom_arg, custom_kwarg=None):
``with_transaction`` starts a new transaction and re-executes
the ``callback``.

The ``callback`` MUST NOT silently handle command errors
without allowing such errors to propagate. Command errors may abort the
transaction on the server, and an attempt to commit the transaction will
be rejected with a ``NoSuchTransaction`` error. For more information see
the `transactions specification`_.

When :meth:`~ClientSession.commit_transaction` raises an exception with
the ``"UnknownTransactionCommitResult"`` error label,
``with_transaction`` retries the commit until the result of the
Expand Down Expand Up @@ -688,6 +694,9 @@ def callback(session, custom_arg, custom_kwarg=None):
:return: The return value of the ``callback``.

.. versionadded:: 3.9

.. _tranactions specification:
https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md#handling-errors-inside-the-callback
"""
start_time = time.monotonic()
while True:
Expand Down
Loading