2023-01-27 21:40:28 +00:00
|
|
|
'''
|
|
|
|
Sketchy network blackoutz, ugly byzantine gens, puedes eschuchar la
|
|
|
|
cancelacion?..
|
|
|
|
|
|
|
|
'''
|
|
|
|
import pytest
|
|
|
|
from _pytest.pathlib import import_path
|
|
|
|
import trio
|
|
|
|
|
|
|
|
from conftest import (
|
|
|
|
examples_dir,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'debug_mode',
|
|
|
|
[False, True],
|
|
|
|
ids=['debug_mode', 'no_debug_mode'],
|
|
|
|
)
|
|
|
|
def test_child_breaks_ipc_channel_during_stream(
|
|
|
|
debug_mode: bool,
|
2023-01-27 22:02:36 +00:00
|
|
|
spawn_backend: str,
|
2023-01-27 21:40:28 +00:00
|
|
|
):
|
|
|
|
'''
|
|
|
|
Ensure we can (purposely) break IPC during streaming and it's still
|
|
|
|
possible for the (simulated) user to kill the actor tree using
|
|
|
|
SIGINT.
|
|
|
|
|
|
|
|
'''
|
2023-01-27 22:02:36 +00:00
|
|
|
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
|
|
|
|
|
2023-01-27 21:40:28 +00:00
|
|
|
mod = import_path(
|
|
|
|
examples_dir() / 'advanced_faults' / 'ipc_failure_during_stream.py',
|
|
|
|
root=examples_dir(),
|
|
|
|
)
|
|
|
|
|
2023-01-27 22:02:36 +00:00
|
|
|
with pytest.raises(expect_final_exc):
|
2023-01-27 21:40:28 +00:00
|
|
|
trio.run(
|
|
|
|
mod.main,
|
|
|
|
debug_mode,
|
2023-01-27 22:02:36 +00:00
|
|
|
spawn_backend,
|
2023-01-27 21:40:28 +00:00
|
|
|
)
|