Add timeout around inf-streamer suite

Since with the new actorc injection seems to be hanging?
Not sure what exactly the issue is but likely races again
during teardown between the `.run_in_actor()` remote-exc capture
and any actorc after the `portal.cancel()`..

Also tossed in a bp to figure out why actorcs aren't actually showing
outside the `trio.run()`..?
actor_cancelled_exc_type
Tyler Goodlet 2025-08-08 15:49:16 -04:00
parent f6ba50979b
commit b8019f90ec
1 changed files with 87 additions and 58 deletions

View File

@ -11,6 +11,9 @@ from itertools import repeat
import pytest
import trio
import tractor
from tractor._exceptions import (
ActorCancelled,
)
from tractor._testing import (
tractor_test,
)
@ -124,7 +127,10 @@ def test_multierror(
) as nursery:
await nursery.run_in_actor(assert_err, name='errorer1')
portal2 = await nursery.run_in_actor(assert_err, name='errorer2')
portal2 = await nursery.run_in_actor(
assert_err,
name='errorer2',
)
# get result(s) from main task
try:
@ -137,7 +143,15 @@ def test_multierror(
# here we should get a ``BaseExceptionGroup`` containing exceptions
# from both subactors
with pytest.raises(BaseExceptionGroup):
with pytest.raises(
expected_exception=(
tractor.RemoteActorError,
# ?TODO, should it be this??
# like `trio`'s strict egs?
BaseExceptionGroup,
),
):
trio.run(main)
@ -233,8 +247,9 @@ async def stream_forever():
@tractor_test
async def test_cancel_infinite_streamer(start_method):
async def test_cancel_infinite_streamer(
start_method: str,
):
# stream for at most 1 seconds
with (
trio.fail_after(4),
@ -291,6 +306,7 @@ async def test_some_cancels_all(
num_actors_and_errs: tuple,
start_method: str,
loglevel: str,
debug_mode: bool,
):
'''
Verify a subset of failed subactors causes all others in
@ -306,6 +322,11 @@ async def test_some_cancels_all(
ria_func,
da_func,
) = num_actors_and_errs
with trio.fail_after(
3
if not debug_mode
else 999
):
try:
async with tractor.open_nursery() as an:
@ -354,13 +375,21 @@ async def test_some_cancels_all(
except first_err as _err:
err = _err
if isinstance(err, BaseExceptionGroup):
assert len(err.exceptions) == num_actors
for exc in err.exceptions:
# TODO, figure out why these aren't being set?
if isinstance(exc, ActorCancelled):
breakpoint()
if isinstance(exc, tractor.RemoteActorError):
assert exc.boxed_type == err_type
else:
assert isinstance(exc, trio.Cancelled)
elif isinstance(err, tractor.RemoteActorError):
assert err.boxed_type == err_type