Example #1
0
 async def start(self):
     if not self._connection:
         self._connection = await self._get_connection()
     self.transaction = self._connection.transaction()
     await self.transaction.start()
     self._old_context_value = current_transaction.get()
     current_transaction.set(self)
Example #2
0
 async def start(self):
     try:
         await self._connection.commit()
         await self._connection.execute('BEGIN')
     except sqlite3.OperationalError as exc:  # pragma: nocoverage
         raise TransactionManagementError(exc)
     self._old_context_value = current_transaction.get()
     current_transaction.set(self)
Example #3
0
 async def rollback(self):
     if self._finalized:
         raise TransactionManagementError('Transaction already finalised')
     self._finalized = True
     await self._connection.rollback()
     if self._pool:
         await self._pool.release(self._connection)
         self._connection = None
     current_transaction.set(self._old_context_value)
Example #4
0
 async def rollback(self):
     try:
         await self.transaction.rollback()
     except asyncpg.exceptions._base.InterfaceError as exc:
         raise TransactionManagementError(exc)
     if self._pool:
         await self._pool.release(self._connection)
         self._connection = None
     current_transaction.set(self._old_context_value)
Example #5
0
 async def commit(self):
     if self._finalized:
         raise TransactionManagementError('Transaction already finalised')
     self._finalized = True
     await self._connection.commit()
     current_transaction.set(self._old_context_value)