]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Use gather instead of wait in tests to be coro friendly
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 6 Mar 2021 02:08:33 +0000 (03:08 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 6 Mar 2021 02:08:33 +0000 (03:08 +0100)
tests/test_concurrency_async.py
tests/test_connection_async.py

index 446db1fb9c61324ecddcb12d32bea9757945e5aa..a75e09f711bd6abfb0b3af953009d13d434fbe3d 100644 (file)
@@ -35,7 +35,7 @@ async def test_commit_concurrency(aconn):
         # Stop the committer thread
         stop = True
 
-    await asyncio.wait([committer(), runner()])
+    await asyncio.gather(committer(), runner())
     assert notices.empty(), "%d notices raised" % notices.qsize()
 
 
@@ -50,7 +50,7 @@ async def test_concurrent_execution(dsn):
 
     workers = [worker(), worker()]
     t0 = time.time()
-    await asyncio.wait(workers)
+    await asyncio.gather(*workers)
     assert time.time() - t0 < 0.8, "something broken in concurrency"
 
 
@@ -75,12 +75,12 @@ async def test_notifies(aconn, dsn):
         async for n in gen:
             ns.append((n, time.time()))
             if len(ns) >= 2:
-                gen.close()
+                await gen.aclose()
 
     ns = []
     t0 = time.time()
     workers = [notifier(), receiver()]
-    await asyncio.wait(workers)
+    await asyncio.gather(*workers)
     assert len(ns) == 2
 
     n, t1 = ns[0]
@@ -116,7 +116,7 @@ async def test_cancel(aconn):
     workers = [worker(), canceller()]
 
     t0 = time.time()
-    await asyncio.wait(workers)
+    await asyncio.gather(*workers)
 
     t1 = time.time()
     assert not errors
index 956cff151c0550517a767fa778189a80d1c14f7e..a25d2d732f2dff7a59175a7be4d36603f33a67fc 100644 (file)
@@ -59,7 +59,7 @@ async def test_connect_timeout():
         elapsed = time.time() - t0
 
     elapsed = 0
-    await asyncio.wait([closer(), connect()])
+    await asyncio.gather(closer(), connect())
     assert elapsed == pytest.approx(1.0, abs=0.05)