Skip to content

Commit

Permalink
Possibly send a Ready.RW value to generators waiting on RW
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dlax authored and dvarrazzo committed Nov 11, 2021
1 parent 1a6000a commit 815a31c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions psycopg/psycopg/waiting.py
Expand Up @@ -29,6 +29,7 @@ class Wait(IntEnum):
class Ready(IntEnum):
R = EVENT_READ
W = EVENT_WRITE
RW = EVENT_READ | EVENT_WRITE


def wait_selector(
Expand Down
6 changes: 2 additions & 4 deletions tests/test_waiting.py
Expand Up @@ -59,11 +59,9 @@ def test_wait(pgconn, timeout):

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))
@linux
def test_wait_ready(waitfn, wait, ready):
def gen():
Expand Down Expand Up @@ -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))
@linux
async def test_wait_ready_async(wait, ready):
def gen():
Expand Down

0 comments on commit 815a31c

Please sign in to comment.