Skip to content

Commit c533288

Browse files
author
TsygulevAA
committed
Add return type to PoolAcquireContext.__aenter__ and rename internal attribute
1 parent 5b14653 commit c533288

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

asyncpg/pool.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,19 +1042,19 @@ async def __aexit__(self, *exc):
10421042

10431043
class PoolAcquireContext:
10441044

1045-
__slots__ = ('timeout', 'connection', 'done', 'pool')
1045+
__slots__ = ('timeout', '_conn', 'done', 'pool')
10461046

10471047
def __init__(self, pool: Pool, timeout: Optional[float]) -> None:
10481048
self.pool = pool
10491049
self.timeout = timeout
1050-
self.connection = None
1050+
self._conn = None
10511051
self.done = False
10521052

1053-
async def __aenter__(self):
1054-
if self.connection is not None or self.done:
1053+
async def __aenter__(self) -> connection.Connection:
1054+
if self._conn is not None or self.done:
10551055
raise exceptions.InterfaceError('a connection is already acquired')
1056-
self.connection = await self.pool._acquire(self.timeout)
1057-
return self.connection
1056+
self._conn = await self.pool._acquire(self.timeout)
1057+
return self._conn
10581058

10591059
async def __aexit__(
10601060
self,
@@ -1063,8 +1063,8 @@ async def __aexit__(
10631063
exc_tb: Optional[TracebackType] = None,
10641064
) -> None:
10651065
self.done = True
1066-
con = self.connection
1067-
self.connection = None
1066+
con = self._conn
1067+
self._conn = None
10681068
await self.pool.release(con)
10691069

10701070
def __await__(self):

0 commit comments

Comments
 (0)