MCPcopy Index your code
hub / github.com/MagicStack/asyncpg / __aexit__

Method __aexit__

asyncpg/transaction.py:70–93  ·  view source on GitHub ↗
(self, extype, ex, tb)

Source from the content-addressed store, hash-verified

68 await self.start()
69
70 async def __aexit__(self, extype, ex, tb):
71 try:
72 self._check_conn_validity('__aexit__')
73 except apg_errors.InterfaceError:
74 if extype is GeneratorExit:
75 # When a PoolAcquireContext is being exited, and there
76 # is an open transaction in an async generator that has
77 # not been iterated fully, there is a possibility that
78 # Pool.release() would race with this __aexit__(), since
79 # both would be in concurrent tasks. In such case we
80 # yield to Pool.release() to do the ROLLBACK for us.
81 # See https://github.com/MagicStack/asyncpg/issues/232
82 # for an example.
83 return
84 else:
85 raise
86
87 try:
88 if extype is not None:
89 await self.__rollback()
90 else:
91 await self.__commit()
92 finally:
93 self._managed = False
94
95 @connresource.guarded
96 async def start(self):

Callers

nothing calls this directly

Calls 3

__rollbackMethod · 0.95
__commitMethod · 0.95
_check_conn_validityMethod · 0.45

Tested by

no test coverage detected