Skip to content

Commit

Permalink
add Pool.closed property as present in aiopg, fixes #463 (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nothing4You authored Feb 2, 2022
1 parent 00d0932 commit 30b9ea5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To be included in 1.0.0 (unreleased)
* Bump minimal PyMySQL version to 1.0.0 #713
* Align % formatting in Cursor.executemany() with Cursor.execute(), literal % now need to be doubled in Cursor.executemany() #714
* Fixed unlimited Pool size not working, this is now working as documented by passing maxsize=0 to create_pool #119
* Added Pool.closed property as present in aiopg #463


0.0.22 (2021-11-14)
Expand Down
9 changes: 8 additions & 1 deletion aiomysql/pool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# copied from aiopg
# based on aiopg pool
# https://github.com/aio-libs/aiopg/blob/master/aiopg/pool.py

import asyncio
Expand Down Expand Up @@ -79,6 +79,13 @@ async def clear(self):
await conn.ensure_closed()
self._cond.notify()

@property
def closed(self):
"""
The readonly property that returns ``True`` if connections is closed.
"""
return self._closed

def close(self):
"""Close pool.
Expand Down
1 change: 1 addition & 0 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ async def wait_closed():
await asyncio.gather(wait_closed(), do_release(c1), do_release(c2))
assert ['release', 'release', 'wait_closed'] == ops
assert 0 == pool.freesize
assert pool.closed


@pytest.mark.run_loop
Expand Down

0 comments on commit 30b9ea5

Please sign in to comment.