File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -446,6 +446,13 @@ async def _initialize(self):
446446
447447 await asyncio .gather (* connect_tasks )
448448
449+ def is_closing (self ):
450+ """Return ``True`` if the pool is closing or is closed.
451+
452+ .. versionadded:: 0.28.0
453+ """
454+ return self ._closed or self ._closing
455+
449456 def get_size (self ):
450457 """Return the current number of connections in this pool.
451458
Original file line number Diff line number Diff line change @@ -740,6 +740,17 @@ async def test_pool_size_and_capacity(self):
740740 self .assertEqual (pool .get_size (), 3 )
741741 self .assertEqual (pool .get_idle_size (), 0 )
742742
743+ async def test_pool_closing (self ):
744+ async with self .create_pool () as pool :
745+ self .assertFalse (pool .is_closing ())
746+ await pool .close ()
747+ self .assertTrue (pool .is_closing ())
748+
749+ async with self .create_pool () as pool :
750+ self .assertFalse (pool .is_closing ())
751+ pool .terminate ()
752+ self .assertTrue (pool .is_closing ())
753+
743754 async def test_pool_handles_transaction_exit_in_asyncgen_1 (self ):
744755 pool = await self .create_pool (database = 'postgres' ,
745756 min_size = 1 , max_size = 1 )
You can’t perform that action at this time.
0 commit comments