]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Limit AsyncAdaptedQueue to Python 3.7
authorFederico Caselli <cfederico87@gmail.com>
Sun, 24 Jan 2021 19:49:06 +0000 (14:49 -0500)
committerFederico Caselli <cfederico87@gmail.com>
Sun, 24 Jan 2021 20:20:11 +0000 (21:20 +0100)
Tests here are failing for python 3.6 due to the lack
of asyncio.run().   It seems to be non-trivial to vendor
a working version of this in Python 3.6 as the tests here
are running it in alternate threads.

The python documentation imports everything directly from the
asyncio package, and it seems that py < 3.8 does not have the
asyncio.exception module

Closes: #5865
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5865
Pull-request-sha: 35cc1fa3f6ff962676f571ae30851f4b4d96762a

Change-Id: I9398c9fb2aa87f3228ce2f59277de732091bd541

lib/sqlalchemy/util/queue.py
test/base/test_concurrency_py3k.py

index 30e388248066f4404d4d52eb6cacc9cba7e59fb7..0cee2f4115239a47d4c4f4a85bc92e1cc398c34b 100644 (file)
@@ -237,7 +237,7 @@ class AsyncAdaptedQueue:
     def put_nowait(self, item):
         try:
             return self._queue.put_nowait(item)
-        except asyncio.queues.QueueFull as err:
+        except asyncio.QueueFull as err:
             compat.raise_(
                 Full(),
                 replace_context=err,
@@ -254,10 +254,7 @@ class AsyncAdaptedQueue:
                 )
             else:
                 return self.await_(self._queue.put(item))
-        except (
-            asyncio.queues.QueueFull,
-            asyncio.exceptions.TimeoutError,
-        ) as err:
+        except (asyncio.QueueFull, asyncio.TimeoutError) as err:
             compat.raise_(
                 Full(),
                 replace_context=err,
@@ -266,7 +263,7 @@ class AsyncAdaptedQueue:
     def get_nowait(self):
         try:
             return self._queue.get_nowait()
-        except asyncio.queues.QueueEmpty as err:
+        except asyncio.QueueEmpty as err:
             compat.raise_(
                 Empty(),
                 replace_context=err,
@@ -283,10 +280,7 @@ class AsyncAdaptedQueue:
                 )
             else:
                 return self.await_(self._queue.get())
-        except (
-            asyncio.queues.QueueEmpty,
-            asyncio.exceptions.TimeoutError,
-        ) as err:
+        except (asyncio.QueueEmpty, asyncio.TimeoutError) as err:
             compat.raise_(
                 Empty(),
                 replace_context=err,
index 1492bc1868350e66ea3edcbf2f690c1e450aad38..08c18b43e3daedf0cdba58eb2c0719c5b34cbbbd 100644 (file)
@@ -161,6 +161,10 @@ class TestAsyncioCompat(fixtures.TestBase):
 
 
 class TestAsyncAdaptedQueue(fixtures.TestBase):
+    # uses asyncio.run() in alternate threads which is not available
+    # in Python 3.6
+    __requires__ = ("python37",)
+
     def test_lazy_init(self):
         run = [False]