Skip to content

Commit 67b01a8

Browse files
authored
Merge pull request #333 from eirnym/await-fix
Using `async with` instead of `with (await pool._cond)`
2 parents 18a2a90 + 085ba52 commit 67b01a8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

aiomysql/pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def _create_pool(minsize=1, maxsize=10, echo=False, pool_recycle=-1,
2525
pool = Pool(minsize=minsize, maxsize=maxsize, echo=echo,
2626
pool_recycle=pool_recycle, loop=loop, **kwargs)
2727
if minsize > 0:
28-
with (await pool._cond):
28+
async with pool._cond:
2929
await pool._fill_free_pool(False)
3030
return pool
3131

@@ -73,7 +73,7 @@ def freesize(self):
7373

7474
async def clear(self):
7575
"""Close all free connections in pool."""
76-
with (await self._cond):
76+
async with self._cond:
7777
while self._free:
7878
conn = self._free.popleft()
7979
await conn.ensure_closed()
@@ -116,7 +116,7 @@ async def wait_closed(self):
116116
conn = self._free.popleft()
117117
conn.close()
118118

119-
with (await self._cond):
119+
async with self._cond:
120120
while self.size > self.freesize:
121121
await self._cond.wait()
122122

@@ -130,7 +130,7 @@ def acquire(self):
130130
async def _acquire(self):
131131
if self._closing:
132132
raise RuntimeError("Cannot acquire connection after closing pool")
133-
with (await self._cond):
133+
async with self._cond:
134134
while True:
135135
await self._fill_free_pool(True)
136136
if self._free:
@@ -186,7 +186,7 @@ async def _fill_free_pool(self, override_min):
186186
self._acquiring -= 1
187187

188188
async def _wakeup(self):
189-
with (await self._cond):
189+
async with self._cond:
190190
self._cond.notify()
191191

192192
def release(self, conn):

0 commit comments

Comments
 (0)