From de7448f2cb908b5f2ff54278be66ff1225936d5a Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Thu, 27 May 2021 22:51:40 +0200 Subject: [PATCH] Make other loop test compatible with py3.10 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 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/base/test_concurrency_py3k.py b/test/base/test_concurrency_py3k.py index 9eba6b82f8..62a21a8034 100644 --- a/test/base/test_concurrency_py3k.py +++ b/test/base/test_concurrency_py3k.py @@ -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() -- 2.47.3