Skip to content

Commit b41c2af

Browse files
committed
Enable session.abort_transaction()
1 parent 3177616 commit b41c2af

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

pymongo/client_session.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,12 @@ def abort_transaction(self):
217217

218218
def _finish_transaction(self, command_name):
219219
if self._current_transaction_opts is None:
220-
raise InvalidOperation("No transaction in progress")
220+
raise InvalidOperation("No transaction started")
221221

222222
if self._server_session.statement_id == 0:
223223
# Not really started.
224224
return
225225

226-
if command_name == 'abortTransaction':
227-
assert False, "Not implemented" # Await server.
228-
229226
try:
230227
# TODO: retryable. And it's weird to pass parse_write_concern_error
231228
# from outside database.py.

test/test_transactions.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,7 @@ def expect_error(expected_result):
234234

235235
def end_sessions(sessions):
236236
for s in sessions.values():
237-
try:
238-
s.commit_transaction()
239-
except Exception:
240-
# Ignore errors from committing without an open transaction.
241-
pass
242-
243-
for s in sessions.values():
237+
# Aborts the transaction if it's open.
244238
s.end_session()
245239

246240

0 commit comments

Comments
 (0)