forked from goodboy/tractor
1
0
Fork 0

Support a delay in daemon actor noops

zombie_lord_infinite
Tyler Goodlet 2021-10-12 12:05:03 -04:00
parent 797bb22981
commit a55ea18c7d
1 changed files with 20 additions and 8 deletions

View File

@ -23,9 +23,9 @@ async def sleep_forever():
await trio.sleep_forever() await trio.sleep_forever()
async def do_nuthin(): async def do_nuthin(sleep=0):
# just nick the scheduler # just nick the scheduler
await trio.sleep(0) await trio.sleep(sleep)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -100,6 +100,7 @@ def test_multierror(arb_addr):
@pytest.mark.parametrize('delay', (0, 0.5)) @pytest.mark.parametrize('delay', (0, 0.5))
@pytest.mark.parametrize( @pytest.mark.parametrize(
'num_subactors', range(25, 26), 'num_subactors', range(25, 26),
# 'num_subactors', range(2, 3),
) )
def test_multierror_fast_nursery(arb_addr, start_method, num_subactors, delay): def test_multierror_fast_nursery(arb_addr, start_method, num_subactors, delay):
"""Verify we raise a ``trio.MultiError`` out of a nursery where """Verify we raise a ``trio.MultiError`` out of a nursery where
@ -222,7 +223,7 @@ async def test_cancel_infinite_streamer(start_method):
# daemon complete quickly delay while single task # daemon complete quickly delay while single task
# actors error after brief delay # actors error after brief delay
(3, tractor.MultiError, AssertionError, (3, tractor.MultiError, AssertionError,
(assert_err, {'delay': 1}), (do_nuthin, {}, False)), (assert_err, {'delay': 1}), (do_nuthin, {'sleep': 0}, False)),
], ],
ids=[ ids=[
'1_run_in_actor_fails', '1_run_in_actor_fails',
@ -325,6 +326,7 @@ async def spawn_and_error(breadth, depth) -> None:
) )
kwargs = { kwargs = {
'name': f'{name}_errorer_{i}', 'name': f'{name}_errorer_{i}',
# 'delay': 0.01,
} }
await nursery.run_in_actor(*args, **kwargs) await nursery.run_in_actor(*args, **kwargs)
@ -389,13 +391,23 @@ async def test_nested_multierrors(loglevel, start_method):
# on windows sometimes spawning is just too slow and # on windows sometimes spawning is just too slow and
# we get back the (sent) cancel signal instead # we get back the (sent) cancel signal instead
if platform.system() == 'Windows': if platform.system() == 'Windows':
assert (subexc.type is trio.MultiError) or ( assert subexc.type in (
subexc.type is tractor.RemoteActorError) trio.MultiError,
tractor.RemoteActorError,
)
else: else:
assert subexc.type is trio.MultiError assert subexc.type in (
trio.MultiError,
trio.Cancelled,
# tractor.RemoteActorError,
)
else: else:
assert (subexc.type is tractor.RemoteActorError) or ( assert subexc.type in (
subexc.type is trio.Cancelled) tractor.RemoteActorError,
trio.Cancelled,
)
else: else:
pytest.fail(f'Got no error from nursery?') pytest.fail(f'Got no error from nursery?')