diff --git a/examples/actor_spawning_and_causality_with_daemon.py b/examples/actor_spawning_and_causality_with_daemon.py index b052871b..2e6824c9 100644 --- a/examples/actor_spawning_and_causality_with_daemon.py +++ b/examples/actor_spawning_and_causality_with_daemon.py @@ -12,9 +12,9 @@ async def movie_theatre_question(): async def main(): """The main ``tractor`` routine. """ - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: - portal = await n.start_actor( + portal = await an.start_actor( 'frank', # enable the actor to run funcs from this current module enable_modules=[__name__], diff --git a/examples/asynchronous_generators.py b/examples/asynchronous_generators.py index b037b085..237794a6 100644 --- a/examples/asynchronous_generators.py +++ b/examples/asynchronous_generators.py @@ -15,9 +15,9 @@ async def stream_forever() -> AsyncIterator[int]: async def main(): - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: - portal = await n.start_actor( + portal = await an.start_actor( 'donny', enable_modules=[__name__], ) diff --git a/examples/debugging/multi_subactor_root_errors.py b/examples/debugging/multi_subactor_root_errors.py index 56f217b4..5aa3a4ff 100644 --- a/examples/debugging/multi_subactor_root_errors.py +++ b/examples/debugging/multi_subactor_root_errors.py @@ -15,10 +15,10 @@ async def name_error(): async def spawn_error(): """"A nested nursery that triggers another ``NameError``. """ - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: return await tractor.to_actor.run( name_error, - an=n, + an=an, name='name_error_1', ) diff --git a/examples/debugging/multi_subactors.py b/examples/debugging/multi_subactors.py index 79775053..63ab5404 100644 --- a/examples/debugging/multi_subactors.py +++ b/examples/debugging/multi_subactors.py @@ -17,10 +17,10 @@ async def name_error(): async def spawn_error(): """"A nested nursery that triggers another ``NameError``. """ - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: return await tractor.to_actor.run( name_error, - an=n, + an=an, name='name_error_1', ) diff --git a/examples/debugging/open_ctx_modnofound.py b/examples/debugging/open_ctx_modnofound.py index 181295aa..450687e2 100644 --- a/examples/debugging/open_ctx_modnofound.py +++ b/examples/debugging/open_ctx_modnofound.py @@ -21,8 +21,8 @@ async def main() -> None: async with tractor.open_nursery( debug_mode=True, - ) as n: - portal = await n.start_actor( + ) as an: + portal = await an.start_actor( 'ctx_child', # XXX: we don't enable the current module in order diff --git a/examples/debugging/per_actor_debug.py b/examples/debugging/per_actor_debug.py index c1bf5cab..189fb45e 100644 --- a/examples/debugging/per_actor_debug.py +++ b/examples/debugging/per_actor_debug.py @@ -6,14 +6,14 @@ async def die(): async def main(): - async with tractor.open_nursery() as tn: + async with tractor.open_nursery() as an: - debug_actor = await tn.start_actor( + debug_actor = await an.start_actor( 'debugged_boi', enable_modules=[__name__], debug_mode=True, ) - crash_boi = await tn.start_actor( + crash_boi = await an.start_actor( 'crash_boi', enable_modules=[__name__], # debug_mode=True, diff --git a/examples/debugging/root_timeout_while_child_crashed.py b/examples/debugging/root_timeout_while_child_crashed.py index 28cb2cf8..043cb5c7 100644 --- a/examples/debugging/root_timeout_while_child_crashed.py +++ b/examples/debugging/root_timeout_while_child_crashed.py @@ -17,11 +17,11 @@ async def main(): tractor.open_nursery( debug_mode=True, # loglevel='debug' # ?XXX required? - ) as n, + ) as an, trio.open_nursery() as tn, ): # spawn the actor.. - portal = await n.start_actor( + portal = await an.start_actor( 'key_error', enable_modules=[__name__], ) diff --git a/examples/debugging/shielded_pause.py b/examples/debugging/shielded_pause.py index 190374ca..5a8c50e7 100644 --- a/examples/debugging/shielded_pause.py +++ b/examples/debugging/shielded_pause.py @@ -74,10 +74,10 @@ async def cancelled_before_pause( async def main(): async with tractor.open_nursery( debug_mode=True, - ) as n: + ) as an: await tractor.to_actor.run( cancelled_before_pause, - an=n, + an=an, ) # ensure the same works in the root actor! diff --git a/examples/debugging/subactor_bp_in_ctx.py b/examples/debugging/subactor_bp_in_ctx.py index 5bfff331..36d4b2b3 100644 --- a/examples/debugging/subactor_bp_in_ctx.py +++ b/examples/debugging/subactor_bp_in_ctx.py @@ -58,8 +58,8 @@ async def main(): debug_mode=True, enable_transports=[tpt], loglevel='devx', - ) as n: - p = await n.start_actor( + ) as an: + p = await an.start_actor( 'bp_boi', enable_modules=[__name__], ) diff --git a/examples/debugging/subactor_breakpoint.py b/examples/debugging/subactor_breakpoint.py index 33b16154..e3a4f250 100644 --- a/examples/debugging/subactor_breakpoint.py +++ b/examples/debugging/subactor_breakpoint.py @@ -17,13 +17,13 @@ async def main(): async with tractor.open_nursery( debug_mode=True, loglevel='cancel', - ) as n: + ) as an: # parks awaiting a result which only arrives once the # user quits (`BdbQuit`s) the child's REPL loop. await tractor.to_actor.run( breakpoint_forever, - an=n, + an=an, ) diff --git a/examples/infected_asyncio_echo_server.py b/examples/infected_asyncio_echo_server.py index e8d29dc3..e3ff2a09 100644 --- a/examples/infected_asyncio_echo_server.py +++ b/examples/infected_asyncio_echo_server.py @@ -50,8 +50,8 @@ async def trio_to_aio_echo_server( async def main(): - async with tractor.open_nursery() as n: - p = await n.start_actor( + async with tractor.open_nursery() as an: + p = await an.start_actor( 'aio_server', enable_modules=[__name__], infect_asyncio=True, diff --git a/examples/integration/open_context_and_sleep.py b/examples/integration/open_context_and_sleep.py index 4c2db3e2..f54b90ae 100644 --- a/examples/integration/open_context_and_sleep.py +++ b/examples/integration/open_context_and_sleep.py @@ -29,9 +29,9 @@ async def main() -> None: )) await proc.wait() # await trio.sleep_forever() - # async with tractor.open_nursery() as n: + # async with tractor.open_nursery() as an: - # portal = await n.start_actor( + # portal = await an.start_actor( # 'rpc_server', # enable_modules=[__name__], # ) diff --git a/examples/parallelism/concurrent_actors_primes.py b/examples/parallelism/concurrent_actors_primes.py index 748861e6..e5b32359 100644 --- a/examples/parallelism/concurrent_actors_primes.py +++ b/examples/parallelism/concurrent_actors_primes.py @@ -55,7 +55,7 @@ async def worker_pool(workers=4): Yes, the workers stay alive (and ready for work) until you close the context. """ - async with tractor.open_nursery() as tn: + async with tractor.open_nursery() as an: portals = [] snd_chan, recv_chan = trio.open_memory_channel(len(PRIMES)) @@ -65,7 +65,7 @@ async def worker_pool(workers=4): # this starts a new sub-actor (process + trio runtime) and # stores it's "portal" for later use to "submit jobs" (ugh). portals.append( - await tn.start_actor( + await an.start_actor( f'worker_{i}', enable_modules=[__name__], ) @@ -80,10 +80,10 @@ async def worker_pool(workers=4): async def send_result(func, value, portal): await snd_chan.send((value, await portal.run(func, n=value))) - async with trio.open_nursery() as n: + async with trio.open_nursery() as tn: for value, portal in zip(sequence, itertools.cycle(portals)): - n.start_soon( + tn.start_soon( send_result, worker_func, value, @@ -98,7 +98,7 @@ async def worker_pool(workers=4): yield _map # tear down all "workers" on pool close - await tn.cancel() + await an.cancel() async def main(): diff --git a/examples/remote_error_propagation.py b/examples/remote_error_propagation.py index 0558bdc7..db9eb9b5 100644 --- a/examples/remote_error_propagation.py +++ b/examples/remote_error_propagation.py @@ -7,17 +7,17 @@ async def assert_err(): async def main(): - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: real_actors = [] for i in range(3): - real_actors.append(await n.start_actor( + real_actors.append(await an.start_actor( f'actor_{i}', enable_modules=[__name__], )) # run one one-shot task actor that will fail immediately; # its error raises right here in the caller's task.. - await tractor.to_actor.run(assert_err, an=n) + await tractor.to_actor.run(assert_err, an=an) # ..as a ``RemoteActorError`` containing an ``AssertionError`` # and all the other actors have been cancelled diff --git a/examples/rpc_bidir_streaming.py b/examples/rpc_bidir_streaming.py index c961bf20..eb4f03cd 100644 --- a/examples/rpc_bidir_streaming.py +++ b/examples/rpc_bidir_streaming.py @@ -31,9 +31,9 @@ async def simple_rpc( async def main() -> None: - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: - portal = await n.start_actor( + portal = await an.start_actor( 'rpc_server', enable_modules=[__name__], ) diff --git a/tests/discovery/test_registrar.py b/tests/discovery/test_registrar.py index f62188ab..e384c22b 100644 --- a/tests/discovery/test_registrar.py +++ b/tests/discovery/test_registrar.py @@ -46,9 +46,9 @@ async def test_reg_then_unreg( async with tractor.open_nursery( registry_addrs=[reg_addr], - ) as n: + ) as an: - portal = await n.start_actor('actor', enable_modules=[__name__]) + portal = await an.start_actor('actor', enable_modules=[__name__]) uid = portal.channel.aid.uid async with tractor.get_registry(reg_addr) as aportal: @@ -62,7 +62,7 @@ async def test_reg_then_unreg( # XXX: can we figure out what the listen addr will be? assert sockaddrs - await n.cancel() # tear down nursery + await an.cancel() # tear down nursery await trio.sleep(0.1) assert uid not in aportal.actor._registry @@ -89,9 +89,9 @@ async def test_reg_then_unreg_maddr( async with tractor.open_nursery( registry_addrs=[maddr_str], - ) as n: + ) as an: - portal = await n.start_actor( + portal = await an.start_actor( 'actor_maddr', enable_modules=[__name__], ) @@ -105,7 +105,7 @@ async def test_reg_then_unreg_maddr( sockaddrs = actor._registry[uid] assert sockaddrs - await n.cancel() + await an.cancel() await trio.sleep(0.1) assert uid not in aportal.actor._registry diff --git a/tests/test_advanced_streaming.py b/tests/test_advanced_streaming.py index 6baa855a..8d5b7d1b 100644 --- a/tests/test_advanced_streaming.py +++ b/tests/test_advanced_streaming.py @@ -219,7 +219,7 @@ def test_dynamic_pub_sub( tractor.open_nursery( registry_addrs=[reg_addr], debug_mode=debug_mode, - ) as n, + ) as an, # bg-schedules the forever-streaming # one-shots below; the user-cancel raise # cancels them all, each reaping its @@ -237,7 +237,7 @@ def test_dynamic_pub_sub( partial( tractor.to_actor.run, publisher, - an=n, + an=an, ) ) @@ -249,7 +249,7 @@ def test_dynamic_pub_sub( partial( tractor.to_actor.run, consumer, - an=n, + an=an, name=f'consumer_{sub}', subs=[sub], ) @@ -260,7 +260,7 @@ def test_dynamic_pub_sub( partial( tractor.to_actor.run, consumer, - an=n, + an=an, name='consumer_dynamic', subs=list(_registry.keys()), ) @@ -370,10 +370,10 @@ def test_reqresp_ontopof_streaming(): timeout = 4 with trio.move_on_after(timeout): - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: # name of this actor will be same as target func - portal = await n.start_actor( + portal = await an.start_actor( 'dual_tasks', enable_modules=[__name__] ) @@ -436,9 +436,9 @@ def test_sigint_both_stream_types(): async def main(): with trio.fail_after(timeout): - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: # name of this actor will be same as target func - portal = await n.start_actor( + portal = await an.start_actor( '2_way', enable_modules=[__name__] ) @@ -551,8 +551,8 @@ def test_local_task_fanout_from_stream( async with tractor.open_nursery( debug_mode=debug_mode, - ) as tn: - p: tractor.Portal = await tn.start_actor( + ) as an: + p: tractor.Portal = await an.start_actor( 'inf_streamer', enable_modules=[__name__], ) diff --git a/tests/test_cancellation.py b/tests/test_cancellation.py index 4f2145eb..54a67981 100644 --- a/tests/test_cancellation.py +++ b/tests/test_cancellation.py @@ -126,7 +126,7 @@ def test_remote_error( async def main(): async with tractor.open_nursery( registry_addrs=[reg_addr], - ) as nursery: + ) as an: # `to_actor.run()` blocks on the one-shot's result and # raises the remote error directly here in the caller's @@ -135,7 +135,7 @@ def test_remote_error( try: await tractor.to_actor.run( assert_err, - an=nursery, + an=an, name='errorer', **args ) @@ -248,16 +248,16 @@ def test_cancel_single_subactor( ''' async with tractor.open_nursery( registry_addrs=[reg_addr], - ) as nursery: + ) as an: - portal = await nursery.start_actor( + portal = await an.start_actor( 'nothin', enable_modules=[__name__], ) assert (await portal.run(do_nothing)) is None if mechanism == 'nursery_cancel': # would hang otherwise - await nursery.cancel() + await an.cancel() else: raise mechanism @@ -289,8 +289,8 @@ async def test_cancel_infinite_streamer( trio.fail_after(4), trio.move_on_after(1) as cancel_scope ): - async with tractor.open_nursery() as n: - portal = await n.start_actor( + async with tractor.open_nursery() as an: + portal = await an.start_actor( 'donny', enable_modules=[__name__], ) @@ -303,7 +303,7 @@ async def test_cancel_infinite_streamer( # we support trio's cancellation system assert cancel_scope.cancelled_caught - assert n.cancel_called + assert an.cancel_called @pytest.mark.parametrize( @@ -698,7 +698,7 @@ async def test_nested_multierrors( async with fail_after_w_trace(timeout): try: async with ( - tractor.open_nursery() as nursery, + tractor.open_nursery() as an, trio.open_nursery() as tn, ): for i in range(subactor_breadth): @@ -706,7 +706,7 @@ async def test_nested_multierrors( partial( tractor.to_actor.run, spawn_and_error, - an=nursery, + an=an, name=f'spawner_{i}', breadth=subactor_breadth, depth=depth, @@ -792,8 +792,8 @@ def test_cancel_via_SIGINT( with trio.fail_after(2): async with tractor.open_nursery( registry_addrs=[reg_addr], - ) as tn: - await tn.start_actor('sucka') + ) as an: + await an.start_actor('sucka') if 'mp' in start_method: time.sleep(0.1) os.kill(pid, signal.SIGINT) @@ -1054,8 +1054,8 @@ def test_fast_graceful_cancel_when_spawn_task_in_soft_proc_wait_for_daemon( start = time.time() try: async with trio.open_nursery() as nurse: - async with tractor.open_nursery() as tn: - p = await tn.start_actor( + async with tractor.open_nursery() as an: + p = await an.start_actor( 'fast_boi', enable_modules=[__name__], ) diff --git a/tests/test_child_manages_service_nursery.py b/tests/test_child_manages_service_nursery.py index 820d9ca0..6c797e6c 100644 --- a/tests/test_child_manages_service_nursery.py +++ b/tests/test_child_manages_service_nursery.py @@ -156,8 +156,8 @@ def test_actor_managed_trio_nursery_task_error_cancels_aio( async def main(): # cancel the nursery shortly after boot - async with tractor.open_nursery() as n: - p = await n.start_actor( + async with tractor.open_nursery() as an: + p = await an.start_actor( 'nursery_mngr', infect_asyncio=asyncio_mode, # TODO, is this enabling debug mode? enable_modules=[__name__], diff --git a/tests/test_inter_peer_cancellation.py b/tests/test_inter_peer_cancellation.py index e0bf5dab..05cea5dc 100644 --- a/tests/test_inter_peer_cancellation.py +++ b/tests/test_inter_peer_cancellation.py @@ -163,12 +163,12 @@ def test_do_not_swallow_error_before_started_by_remote_contextcancelled( async def main(): async with tractor.open_nursery( debug_mode=debug_mode, - ) as n: - portal = await n.start_actor( + ) as an: + portal = await an.start_actor( 'errorer', enable_modules=[__name__], ) - await n.start_actor( + await an.start_actor( 'sleeper', enable_modules=[__name__], ) diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py index 550ac4e1..27f2058d 100644 --- a/tests/test_pubsub.py +++ b/tests/test_pubsub.py @@ -139,9 +139,9 @@ async def test_required_args(callwith_expecterror): with pytest.raises(err): await func(**kwargs) else: - async with tractor.open_nursery() as n: + async with tractor.open_nursery() as an: - portal = await n.start_actor( + portal = await an.start_actor( name='pubber', enable_modules=[__name__], ) @@ -180,7 +180,7 @@ def test_multi_actor_subs_arbiter_pub( tractor.open_nursery( registry_addrs=[reg_addr], enable_modules=[__name__], - ) as n, + ) as an, trio.open_nursery() as tn, ): @@ -188,7 +188,7 @@ def test_multi_actor_subs_arbiter_pub( if pub_actor == 'streamer': # start the publisher as a daemon - master_portal = await n.start_actor( + master_portal = await an.start_actor( 'streamer', enable_modules=[__name__], ) @@ -215,11 +215,11 @@ def test_multi_actor_subs_arbiter_pub( ): pass # expected once we `cancel_actor()` below - even_portal = await n.start_actor( + even_portal = await an.start_actor( 'evens', enable_modules=[__name__], ) - odd_portal = await n.start_actor( + odd_portal = await an.start_actor( 'odds', enable_modules=[__name__], ) @@ -294,9 +294,9 @@ def test_single_subactor_pub_multitask_subs( async with tractor.open_nursery( registry_addrs=[reg_addr], enable_modules=[__name__], - ) as n: + ) as an: - portal = await n.start_actor( + portal = await an.start_actor( 'streamer', enable_modules=[__name__], ) diff --git a/tests/test_rpc.py b/tests/test_rpc.py index 465f9483..a033b6af 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -107,13 +107,13 @@ def test_rpc_errors( # do that if actually debugging subactor but keep it # disabled for the test. # debug_mode=True, - ) as n: + ) as an: actor = tractor.current_actor() assert actor.is_registrar await tractor.to_actor.run( sleep_back_actor, - an=n, + an=an, actor_name=subactor_requests_to, name='subactor', diff --git a/tests/test_spawning.py b/tests/test_spawning.py index 004a2a90..ce9db115 100644 --- a/tests/test_spawning.py +++ b/tests/test_spawning.py @@ -202,10 +202,10 @@ def test_loglevel_propagated_to_subactor( start_method=start_method, registry_addrs=[reg_addr], - ) as tn: + ) as an: await tractor.to_actor.run( check_loglevel, - an=tn, + an=an, loglevel=level, level=level, )