Skip to content

Commit e6da2fa

Browse files
committed
fix improper handling of connection closing in pool
- use `conn.ensure_closed()` in `fill_free_pool()` and `wait_closed()` - fix docstring of `Connection.ensure_closed`
1 parent 09bea07 commit e6da2fa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

asyncmy/connection.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class Connection:
354354
return self._last_usage
355355

356356
async def ensure_closed(self):
357-
"""Close connection without QUIT message."""
357+
"""Send QUIT message and close connection."""
358358
if self._connected:
359359
send_data = i.pack(1) + B.pack(COM_QUIT)
360360
self._write_bytes(send_data)

asyncmy/pool.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Pool(asyncio.AbstractServer):
9595

9696
while self._free:
9797
conn = self._free.popleft()
98-
conn.close()
98+
await conn.ensure_closed()
9999

100100
async with self._cond:
101101
while self.size > self.freesize:
@@ -133,7 +133,7 @@ class Pool(asyncio.AbstractServer):
133133

134134
elif self._recycle > -1 and self._loop.time() - conn.last_usage > self._recycle:
135135
self._free.pop()
136-
conn.close()
136+
await conn.ensure_closed()
137137

138138
else:
139139
self._free.rotate()

0 commit comments

Comments
 (0)