66from django .db import DEFAULT_DB_ALIAS
77from django .db .backends .base .base import BaseDatabaseWrapper
88from django .db .backends .utils import debug_transaction
9- from django .db .transaction import TransactionManagementError
109from django .utils .asyncio import async_unsafe
1110from django .utils .functional import cached_property
1211from pymongo .collection import Collection
@@ -247,11 +246,6 @@ def close_pool(self):
247246 def cursor (self ):
248247 return Cursor ()
249248
250- def validate_no_atomic_block (self ):
251- """Raise an error if an atomic block is active."""
252- if self .in_atomic_block_mongo :
253- raise TransactionManagementError ("This is forbidden when an 'atomic' block is active." )
254-
255249 def get_database_version (self ):
256250 """Return a tuple of the database's version."""
257251 return tuple (self .connection .server_info ()["versionArray" ])
@@ -263,28 +257,19 @@ def _start_transaction(self):
263257 self .session .start_transaction ()
264258
265259 def commit_mongo (self ):
266- self .validate_thread_sharing ()
267- self .validate_no_atomic_block ()
268260 if self .session :
269261 with debug_transaction (self , "session.commit_transaction()" ):
270262 self .session .commit_transaction ()
271263 self ._end_session ()
272- # A successful commit means that the database connection works.
273- self .errors_occurred = False
274264 self .run_commit_hooks_on_set_autocommit_on = True
275265
276266 @async_unsafe
277267 def rollback_mongo (self ):
278268 """Roll back a MongoDB transaction and reset the dirty flag."""
279- self .validate_thread_sharing ()
280- self .validate_no_atomic_block ()
281269 if self .session :
282270 with debug_transaction (self , "session.abort_transaction()" ):
283271 self .session .abort_transaction ()
284272 self ._end_session ()
285- # A successful rollback means that the database connection works.
286- self .errors_occurred = False
287- self .needs_rollback_mongo = False
288273 self .run_on_commit = []
289274
290275 def _end_session (self ):
0 commit comments