Skip to content

Commit

Permalink
test cancel wait without pidfd
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Dec 19, 2024
1 parent 2722418 commit 8858398
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/trio/_tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ async def test_multi_wait(background_process: BackgroundProcessType) -> None:
proc.kill()


@background_process_param
async def test_multi_wait_no_pidfd(background_process: BackgroundProcessType) -> None:
with mock.patch("trio._subprocess.can_try_pidfd_open", new=False):
async with background_process(SLEEP(10)) as proc:
# Check that wait (including multi-wait) tolerates being cancelled
async with _core.open_nursery() as nursery:
nursery.start_soon(proc.wait)
nursery.start_soon(proc.wait)
nursery.start_soon(proc.wait)
await wait_all_tasks_blocked()
nursery.cancel_scope.cancel()

# Now try waiting for real
async with _core.open_nursery() as nursery:
nursery.start_soon(proc.wait)
nursery.start_soon(proc.wait)
nursery.start_soon(proc.wait)
await wait_all_tasks_blocked()
proc.kill()


COPY_STDIN_TO_STDOUT_AND_BACKWARD_TO_STDERR = python(
"data = sys.stdin.buffer.read(); "
"sys.stdout.buffer.write(data); "
Expand Down

0 comments on commit 8858398

Please sign in to comment.