]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Possibly send a Ready.RW value to generators waiting on RW 120/head
authorDenis Laxalde <denis.laxalde@dalibo.com>
Tue, 12 Oct 2021 13:40:36 +0000 (15:40 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 16 Nov 2021 10:28:18 +0000 (11:28 +0100)
In some generators, we might be interested in receiving both read-ready
and write-ready event at the same time.

Per previous commits, all wait*() functions support this.

This is covered by test_wait_ready(), which now maps Wait.RW to
Ready.RW.

psycopg/psycopg/waiting.py
tests/test_waiting.py

index 6355043095cf5438a525b8eb0a4d346c7fd46497..3c2185464caaa24a3c5be33ad2b7d9c17f8994c1 100644 (file)
@@ -29,6 +29,7 @@ class Wait(IntEnum):
 class Ready(IntEnum):
     R = EVENT_READ
     W = EVENT_WRITE
+    RW = EVENT_READ | EVENT_WRITE
 
 
 def wait_selector(
index 21d94b144a0ff1ed184754a49fb3a4ba414bdfae..10e99bbbc0f698e7370d09b279a3799c7310a80e 100644 (file)
@@ -59,11 +59,9 @@ if hasepoll:
 
 waits, wids = list(zip(*waits_and_ids))
 
-readys = [waiting.Ready.R, waiting.Ready.W, waiting.Ready.R | waiting.Ready.W]
-
 
 @pytest.mark.parametrize("waitfn", waits, ids=wids)
-@pytest.mark.parametrize("wait, ready", zip(waiting.Wait, readys))
+@pytest.mark.parametrize("wait, ready", zip(waiting.Wait, waiting.Ready))
 @skip_if_not_linux
 def test_wait_ready(waitfn, wait, ready):
     def gen():
@@ -132,7 +130,7 @@ async def test_wait_async(pgconn):
 
 
 @pytest.mark.asyncio
-@pytest.mark.parametrize("wait, ready", zip(waiting.Wait, readys))
+@pytest.mark.parametrize("wait, ready", zip(waiting.Wait, waiting.Ready))
 @skip_if_not_linux
 async def test_wait_ready_async(wait, ready):
     def gen():