File tree 2 files changed +18
-0
lines changed
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):
446
446
447
447
await asyncio .gather (* connect_tasks )
448
448
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
+
449
456
def get_size (self ):
450
457
"""Return the current number of connections in this pool.
451
458
Original file line number Diff line number Diff line change @@ -740,6 +740,17 @@ async def test_pool_size_and_capacity(self):
740
740
self .assertEqual (pool .get_size (), 3 )
741
741
self .assertEqual (pool .get_idle_size (), 0 )
742
742
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
+
743
754
async def test_pool_handles_transaction_exit_in_asyncgen_1 (self ):
744
755
pool = await self .create_pool (database = 'postgres' ,
745
756
min_size = 1 , max_size = 1 )
You can’t perform that action at this time.
0 commit comments