Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion aiomysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,12 @@ async def _read_bytes(self, num_bytes):
return data

def _write_bytes(self, data):
return self._writer.write(data)
try:
return self._writer.write(data)
except RuntimeError as e:
self.close()
msg = "Lost connection to MySQL server during query ({})".format(e)
raise OperationalError(2013, msg) from e

async def _read_query_result(self, unbuffered=False):
self._result = None
Expand Down
4 changes: 2 additions & 2 deletions aiomysql/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ async def _fill_free_pool(self, override_min):
**self._conn_kwargs)
# raise exception if pool is closing
self._free.append(conn)
self._cond.notify()
finally:
self._acquiring -= 1
self._cond.notify()
if self._free:
return

Expand All @@ -196,9 +196,9 @@ async def _fill_free_pool(self, override_min):
**self._conn_kwargs)
# raise exception if pool is closing
self._free.append(conn)
self._cond.notify()
finally:
self._acquiring -= 1
self._cond.notify()

async def _wakeup(self):
async with self._cond:
Expand Down
Loading