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 committed Nov 12, 2021
1 parent 37bdcf9 commit 4e123fd
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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))
@skip_if_not_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))
@skip_if_not_linux
async def test_wait_ready_async(wait, ready):
def gen():
Expand Down

0 comments on commit 4e123fd

Please sign in to comment.