From 4cf0450c5204429651a8a1cd34d986006796f633 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Tue, 12 Oct 2021 15:40:36 +0200 Subject: [PATCH] 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. --- psycopg/psycopg/waiting.py | 1 + tests/test_waiting.py | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) 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(): -- 2.47.2