]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Change type of `wait` in `pool_async.py` 195/head
authorNikita Sobolev <mail@sobolevn.me>
Sun, 2 Jan 2022 11:51:11 +0000 (14:51 +0300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 2 Jan 2022 15:51:46 +0000 (16:51 +0100)
Will become an incompatible type in assignment with the release of
https://github.com/python/typeshed/pull/6783

psycopg_pool/psycopg_pool/pool_async.py

index 80dc00f833284ed581dba705f8a899591fd6de36..597f306aa13ee4c4b841ceb3ef74bfa3268d928f 100644 (file)
@@ -239,10 +239,11 @@ class AsyncConnectionPool(BasePool[AsyncConnection[Any]]):
 
         # Wait for the worker threads to terminate
         wait = asyncio.gather(self._sched_runner, *self._workers)
-        if timeout > 0:
-            wait = asyncio.wait_for(asyncio.shield(wait), timeout=timeout)
         try:
-            await wait
+            if timeout > 0:
+                await asyncio.wait_for(asyncio.shield(wait), timeout=timeout)
+            else:
+                await wait
         except asyncio.TimeoutError:
             logger.warning(
                 "couldn't stop pool %r tasks within %s seconds",