From: Daniele Varrazzo Date: Sun, 8 Oct 2023 17:31:07 +0000 (+0200) Subject: style(pool): more explicit error message for pool open with no loop X-Git-Tag: pool-3.1.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=806d7c7d15b8295f4a1a1bb030cc797726ddafcd;p=thirdparty%2Fpsycopg.git style(pool): more explicit error message for pool open with no loop --- diff --git a/psycopg_pool/psycopg_pool/pool_async.py b/psycopg_pool/psycopg_pool/pool_async.py index fa310b129..e08f0c494 100644 --- a/psycopg_pool/psycopg_pool/pool_async.py +++ b/psycopg_pool/psycopg_pool/pool_async.py @@ -232,8 +232,12 @@ class AsyncConnectionPool(BasePool[AsyncConnection[Any]]): if not self._closed: return - # Throw a RuntimeError if the pool is open outside a running loop. - asyncio.get_running_loop() + try: + asyncio.get_running_loop() + except RuntimeError: + raise RuntimeError( + f"{type(self).__name__} open with no running loop" + ) from None self._check_open()