"The transaction is inactive due to a rollback in a "
"subtransaction. Issue rollback() to cancel the transaction.")
- def _assert_is_open(self):
+ def _assert_is_open(self, error_msg="The transaction is closed"):
if self.session is None:
- raise sa_exc.InvalidRequestError("The transaction is closed")
+ raise sa_exc.InvalidRequestError(error_msg)
@property
def _is_transaction_boundary(self):
return self
def __exit__(self, type, value, traceback):
+ self._assert_is_open("Cannot end transaction context. The transaction was closed from within the context")
if self.session.transaction is None:
return
if type is None: