Handle `mp` spawn method cases in test suite
parent
1d92f2552a
commit
7fddb4416b
|
@ -64,14 +64,17 @@ async def recv_and_spawn_net_killers(
|
||||||
if i > 80:
|
if i > 80:
|
||||||
n.start_soon(break_channel_silently_then_error, stream)
|
n.start_soon(break_channel_silently_then_error, stream)
|
||||||
n.start_soon(close_stream_and_error, stream)
|
n.start_soon(close_stream_and_error, stream)
|
||||||
|
await trio.sleep_forever()
|
||||||
|
|
||||||
|
|
||||||
async def main(
|
async def main(
|
||||||
debug_mode: bool = True,
|
debug_mode: bool = False,
|
||||||
|
start_method: str = 'trio',
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
async with open_nursery(
|
async with open_nursery(
|
||||||
|
start_method=start_method,
|
||||||
|
|
||||||
# NOTE: even debugger is used we shouldn't get
|
# NOTE: even debugger is used we shouldn't get
|
||||||
# a hang since it never engages due to broken IPC
|
# a hang since it never engages due to broken IPC
|
||||||
|
@ -88,6 +91,8 @@ async def main(
|
||||||
) as (ctx, sent):
|
) as (ctx, sent):
|
||||||
async with ctx.open_stream() as stream:
|
async with ctx.open_stream() as stream:
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
|
|
||||||
|
# this may break in the mp_spawn case
|
||||||
await stream.send(i)
|
await stream.send(i)
|
||||||
|
|
||||||
with trio.move_on_after(2) as cs:
|
with trio.move_on_after(2) as cs:
|
||||||
|
|
|
@ -159,7 +159,7 @@ def loglevel(request):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def spawn_backend(request):
|
def spawn_backend(request) -> str:
|
||||||
return request.config.option.spawn_backend
|
return request.config.option.spawn_backend
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ from conftest import (
|
||||||
)
|
)
|
||||||
def test_child_breaks_ipc_channel_during_stream(
|
def test_child_breaks_ipc_channel_during_stream(
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
|
spawn_backend: str,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Ensure we can (purposely) break IPC during streaming and it's still
|
Ensure we can (purposely) break IPC during streaming and it's still
|
||||||
|
@ -26,13 +27,22 @@ def test_child_breaks_ipc_channel_during_stream(
|
||||||
SIGINT.
|
SIGINT.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
expect_final_exc = KeyboardInterrupt
|
||||||
|
|
||||||
|
if spawn_backend != 'trio':
|
||||||
|
if debug_mode:
|
||||||
|
pytest.skip('`debug_mode` only supported on `trio` spawner')
|
||||||
|
|
||||||
|
expect_final_exc = trio.ClosedResourceError
|
||||||
|
|
||||||
mod = import_path(
|
mod = import_path(
|
||||||
examples_dir() / 'advanced_faults' / 'ipc_failure_during_stream.py',
|
examples_dir() / 'advanced_faults' / 'ipc_failure_during_stream.py',
|
||||||
root=examples_dir(),
|
root=examples_dir(),
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(KeyboardInterrupt):
|
with pytest.raises(expect_final_exc):
|
||||||
trio.run(
|
trio.run(
|
||||||
mod.main,
|
mod.main,
|
||||||
debug_mode,
|
debug_mode,
|
||||||
|
spawn_backend,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue