From: Denis Laxalde Date: Tue, 12 Oct 2021 13:40:36 +0000 (+0200) Subject: Possibly send a Ready.RW value to generators waiting on RW X-Git-Tag: 3.0.5~10^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F120%2Fhead;p=thirdparty%2Fpsycopg.git Possibly send a Ready.RW value to generators waiting on RW 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. --- diff --git a/psycopg/psycopg/waiting.py b/psycopg/psycopg/waiting.py index 635504309..3c2185464 100644 --- a/psycopg/psycopg/waiting.py +++ b/psycopg/psycopg/waiting.py @@ -29,6 +29,7 @@ class Wait(IntEnum): class Ready(IntEnum): R = EVENT_READ W = EVENT_WRITE + RW = EVENT_READ | EVENT_WRITE def wait_selector( diff --git a/tests/test_waiting.py b/tests/test_waiting.py index 21d94b144..10e99bbbc 100644 --- a/tests/test_waiting.py +++ b/tests/test_waiting.py @@ -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():