diff options
author | Federico Caselli <cfederico87@gmail.com> | 2021-05-27 22:51:40 +0200 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2021-05-27 22:51:40 +0200 |
commit | de7448f2cb908b5f2ff54278be66ff1225936d5a (patch) | |
tree | 205559472d0fe822118e9d5612142a7e24d14105 /test/base/test_concurrency_py3k.py | |
parent | 4c6f10d7a3665e895b095db2f29ad04a9ac71ded (diff) | |
download | sqlalchemy-de7448f2cb908b5f2ff54278be66ff1225936d5a.tar.gz |
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
Diffstat (limited to 'test/base/test_concurrency_py3k.py')
-rw-r--r-- | test/base/test_concurrency_py3k.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/base/test_concurrency_py3k.py b/test/base/test_concurrency_py3k.py index 9eba6b82f..62a21a803 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() |