Skip to content

Commit b3e2e07

Browse files
committed
Test wait_readable
1 parent 88f5d9d commit b3e2e07

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313

1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
os: [ubuntu-latest, windows-latest, macos-latest]
1718
python-version:
@@ -32,7 +33,9 @@ jobs:
3233
with:
3334
python-version: ${{ matrix.python-version }}
3435
- name: Install dependencies
35-
run: pip install -e ".[test]"
36+
run: |
37+
pip install -e ".[test]"
38+
pip install git+https://github.com/davidbrochart/anyio.git@show-error#egg=anyio --ignore-installed
3639
- name: Check with mypy and ruff
3740
if: ${{ (matrix.python-version == '3.13') && (matrix.os == 'ubuntu-latest') }}
3841
run: |
@@ -41,7 +44,7 @@ jobs:
4144
ruff check src
4245
- name: Run tests
4346
if: ${{ !((matrix.python-version == '3.13') && (matrix.os == 'ubuntu-latest')) }}
44-
run: pytest --color=yes -v tests
47+
run: pytest --color=yes -v tests -s
4548
- name: Run code coverage
4649
if: ${{ (matrix.python-version == '3.13') && (matrix.os == 'ubuntu-latest') }}
4750
run: |

tests/test_socket.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import json
2+
import socket
23

34
import pytest
45
import zmq
5-
from anyio import create_task_group, fail_after, move_on_after, sleep, to_thread
6+
from anyio import create_task_group, fail_after, move_on_after, sleep, to_thread, wait_all_tasks_blocked, wait_readable
67
from anyioutils import CancelledError, Future, create_task
78
from zmq_anyio import Poller, Socket
89

@@ -342,3 +343,24 @@ async def test_close(create_bound_pair):
342343
await tg.start(b.start)
343344
a.close()
344345
b.close()
346+
await sleep(0.1)
347+
348+
349+
async def test_wait_readable():
350+
with fail_after(1):
351+
s1, s2 = socket.socketpair()
352+
with s1, s2:
353+
s1.setblocking(False)
354+
s2.setblocking(False)
355+
async with create_task_group() as tg:
356+
tg.start_soon(wait_readable, s2)
357+
await wait_all_tasks_blocked()
358+
await sleep(0.1)
359+
tg.cancel_scope.cancel()
360+
361+
s1, s2 = socket.socketpair()
362+
with s1, s2:
363+
s1.setblocking(False)
364+
s2.setblocking(False)
365+
s1.send(b"\x00")
366+
await wait_readable(s2)

0 commit comments

Comments
 (0)