]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix AsyncEngine connect() bug when pool is exhausted
authorFantix King <fantix.king@gmail.com>
Mon, 31 Aug 2020 07:41:00 +0000 (03:41 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Mon, 31 Aug 2020 07:41:00 +0000 (03:41 -0400)
### Description

Decorating the referenced `await_fallback` with `staticmethod` would stop `AsyncAdaptedQueue.await_` from being treated as a bound method.

### Checklist

This pull request is:

- [x] A short code fix
    Fixes #5546

**Have a nice day!**

Closes: #5547
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5547
Pull-request-sha: 6f18ee290e7d9fe24ce2a4a4ed8069b46082ca18

Change-Id: Ie335ee650f1dee0d1fce59e448217a48307b3435

lib/sqlalchemy/util/queue.py
test/ext/asyncio/test_engine_py3k.py

index 5f71c7bd6f29fd35ba55776ed86ae5ef8b0a41e8..58a88e4ede9e291fcfe91f65b3a5444359fbf0a9 100644 (file)
@@ -202,7 +202,7 @@ class Queue:
 
 
 class AsyncAdaptedQueue:
-    await_ = await_fallback
+    await_ = staticmethod(await_fallback)
 
     def __init__(self, maxsize=0, use_lifo=False):
         if use_lifo:
index ec513cb649d2b2325bd99f8addd9732df34681e5..705df465b4d777ae5aaeebfbfc080a4fb2dada1f 100644 (file)
@@ -1,3 +1,5 @@
+import asyncio
+
 from sqlalchemy import Column
 from sqlalchemy import delete
 from sqlalchemy import exc
@@ -135,6 +137,16 @@ class AsyncEngineTest(EngineFixture):
                 trans.rollback(),
             )
 
+    @async_test
+    async def test_pool_exhausted(self, async_engine):
+        engine = create_async_engine(
+            testing.db.url, pool_size=1, max_overflow=0, pool_timeout=0.1,
+        )
+        async with engine.connect():
+            await assert_raises_message_async(
+                asyncio.TimeoutError, "", engine.connect(),
+            )
+
 
 class AsyncResultTest(EngineFixture):
     @testing.combinations(