Port remaining tests to pass func refs

func_refs_always
Tyler Goodlet 2020-12-22 10:35:05 -05:00
parent 493f2efb50
commit 0eba5f4708
4 changed files with 12 additions and 12 deletions

View File

@ -137,7 +137,7 @@ def test_cancel_single_subactor(arb_addr, mechanism):
portal = await nursery.start_actor( portal = await nursery.start_actor(
'nothin', rpc_module_paths=[__name__], 'nothin', rpc_module_paths=[__name__],
) )
assert (await portal.run(__name__, 'do_nothing')) is None assert (await portal.run(do_nothing)) is None
if mechanism == 'nursery_cancel': if mechanism == 'nursery_cancel':
# would hang otherwise # would hang otherwise
@ -173,7 +173,7 @@ async def test_cancel_infinite_streamer(start_method):
# this async for loop streams values from the above # this async for loop streams values from the above
# async generator running in a separate process # async generator running in a separate process
async for letter in await portal.run(__name__, 'stream_forever'): async for letter in await portal.run(stream_forever):
print(letter) print(letter)
# we support trio's cancellation system # we support trio's cancellation system
@ -247,7 +247,8 @@ async def test_some_cancels_all(num_actors_and_errs, start_method, loglevel):
# if this function fails then we should error here # if this function fails then we should error here
# and the nursery should teardown all other actors # and the nursery should teardown all other actors
try: try:
await portal.run(__name__, func.__name__, **kwargs) await portal.run(func, **kwargs)
except tractor.RemoteActorError as err: except tractor.RemoteActorError as err:
assert err.type == err_type assert err.type == err_type
# we only expect this first error to propogate # we only expect this first error to propogate

View File

@ -58,7 +58,7 @@ async def subs(
async with tractor.find_actor(pub_actor_name) as portal: async with tractor.find_actor(pub_actor_name) as portal:
stream = await portal.run( stream = await portal.run(
__name__, 'pubber', pubber,
topics=which, topics=which,
seed=seed, seed=seed,
) )
@ -76,7 +76,7 @@ async def subs(
await stream.aclose() await stream.aclose()
stream = await portal.run( stream = await portal.run(
__name__, 'pubber', pubber,
topics=['odd'], topics=['odd'],
seed=seed, seed=seed,
) )

View File

@ -70,9 +70,9 @@ async def test_movie_theatre_convo(start_method):
rpc_module_paths=[__name__], rpc_module_paths=[__name__],
) )
print(await portal.run(__name__, 'movie_theatre_question')) print(await portal.run(movie_theatre_question))
# call the subactor a 2nd time # call the subactor a 2nd time
print(await portal.run(__name__, 'movie_theatre_question')) print(await portal.run(movie_theatre_question))
# the async with will block here indefinitely waiting # the async with will block here indefinitely waiting
# for our actor "frank" to complete, we cancel 'frank' # for our actor "frank" to complete, we cancel 'frank'

View File

@ -50,7 +50,7 @@ async def context_stream(ctx, sequence):
assert cs.cancelled_caught assert cs.cancelled_caught
async def stream_from_single_subactor(stream_func_name): async def stream_from_single_subactor(stream_func):
"""Verify we can spawn a daemon actor and retrieve streamed data. """Verify we can spawn a daemon actor and retrieve streamed data.
""" """
async with tractor.find_actor('streamerd') as portals: async with tractor.find_actor('streamerd') as portals:
@ -67,8 +67,7 @@ async def stream_from_single_subactor(stream_func_name):
seq = range(10) seq = range(10)
stream = await portal.run( stream = await portal.run(
__name__, stream_func, # one of the funcs above
stream_func_name, # one of the funcs above
sequence=list(seq), # has to be msgpack serializable sequence=list(seq), # has to be msgpack serializable
) )
# it'd sure be nice to have an asyncitertools here... # it'd sure be nice to have an asyncitertools here...
@ -96,7 +95,7 @@ async def stream_from_single_subactor(stream_func_name):
@pytest.mark.parametrize( @pytest.mark.parametrize(
'stream_func', ['async_gen_stream', 'context_stream'] 'stream_func', [async_gen_stream, context_stream]
) )
def test_stream_from_single_subactor(arb_addr, start_method, stream_func): def test_stream_from_single_subactor(arb_addr, start_method, stream_func):
"""Verify streaming from a spawned async generator. """Verify streaming from a spawned async generator.
@ -104,7 +103,7 @@ def test_stream_from_single_subactor(arb_addr, start_method, stream_func):
tractor.run( tractor.run(
partial( partial(
stream_from_single_subactor, stream_from_single_subactor,
stream_func_name=stream_func, stream_func=stream_func,
), ),
arbiter_addr=arb_addr, arbiter_addr=arb_addr,
start_method=start_method, start_method=start_method,