Skip to content

Commit 14ec1b3

Browse files
committed
(hopefully) Fix pool.transaction to always close connection
1 parent c4d146a commit 14ec1b3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

asyncpgsa/transactionmanager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12

23

34
class ConnectionTransactionContextManager:
@@ -35,5 +36,10 @@ async def __aenter__(self):
3536
return con
3637

3738
async def __aexit__(self, exc_type, exc_val, exc_tb):
38-
await self.transaction.__aexit__(exc_type, exc_val, exc_tb)
39-
await self.acquire_context.__aexit__(exc_type, exc_val, exc_tb)
39+
async def _close():
40+
try:
41+
await self.transaction.__aexit__(exc_type, exc_val, exc_tb)
42+
finally:
43+
await self.acquire_context.__aexit__(exc_type, exc_val, exc_tb)
44+
45+
await asyncio.shield(_close())

asyncpgsa/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.19.1'
1+
__version__ = '0.19.2'

0 commit comments

Comments
 (0)