]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Make other loop test compatible with py3.10
authorFederico Caselli <cfederico87@gmail.com>
Thu, 27 May 2021 20:51:40 +0000 (22:51 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 27 May 2021 20:51:40 +0000 (22:51 +0200)
Python 3.10 fixes the issue where the loop would bind to a queue
on instantiation. Now an object binds to the loop only when first
needs it. I've looked at queues, but I'm assuming locks behave
the same,

Change-Id: Ibb8d263cdea230e9c85709528c21da31d0df2e65

test/base/test_concurrency_py3k.py

index 9eba6b82f84e56de53455aacadd17f976a4e0071..62a21a80347de27186bbbdcc35bf803115dd8c4e 100644 (file)
@@ -11,7 +11,6 @@ from sqlalchemy.testing import is_true
 from sqlalchemy.util import asyncio
 from sqlalchemy.util import await_fallback
 from sqlalchemy.util import await_only
-from sqlalchemy.util import compat
 from sqlalchemy.util import greenlet_spawn
 from sqlalchemy.util import queue
 
@@ -185,7 +184,8 @@ class TestAsyncAdaptedQueue(fixtures.TestBase):
 
         is_true(run[0])
 
-    def test_error_other_loop(self):
+    @async_test
+    async def test_error_other_loop(self):
         run = [False]
 
         def thread_go(q):
@@ -193,19 +193,20 @@ class TestAsyncAdaptedQueue(fixtures.TestBase):
                 eq_(q.get(block=False), 1)
                 q.get(timeout=0.1)
 
-            if compat.py310:
-                # TODO: I don't really know what this means in 3.10
-                with expect_raises(queue.Empty):
-                    asyncio.run(greenlet_spawn(go))
-            else:
-                with expect_raises_message(
-                    RuntimeError, "Task .* attached to a different loop"
-                ):
-                    asyncio.run(greenlet_spawn(go))
+            with expect_raises_message(
+                RuntimeError, ".* to a different .*loop"
+            ):
+                asyncio.run(greenlet_spawn(go))
 
             run[0] = True
 
         q = queue.AsyncAdaptedQueue()
+
+        def prime():
+            with expect_raises(queue.Empty):
+                q.get(timeout=0.1)
+
+        await greenlet_spawn(prime)
         q.put_nowait(1)
         t = threading.Thread(target=thread_go, args=[q])
         t.start()