Skip to content

Commit

Permalink
Merge pull request #198 from goodboy/kinda_drop_run
Browse files Browse the repository at this point in the history
Kinda drop run
  • Loading branch information
goodboy authored Feb 25, 2021
2 parents 35775c6 + 47565cf commit 49a02e6
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 138 deletions.
11 changes: 7 additions & 4 deletions examples/debugging/multi_daemon_subactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ async def name_error():
async def main():
"""Test breakpoint in a streaming actor.
"""
async with tractor.open_nursery() as n:
async with tractor.open_nursery(
debug_mode=True,
loglevel='error',
) as n:

p0 = await n.start_actor('bp_forever', rpc_module_paths=[__name__])
p1 = await n.start_actor('name_error', rpc_module_paths=[__name__])
p0 = await n.start_actor('bp_forever', enable_modules=[__name__])
p1 = await n.start_actor('name_error', enable_modules=[__name__])

# retreive results
stream = await p0.run(breakpoint_forever)
await p1.run(name_error)


if __name__ == '__main__':
tractor.run(main, debug_mode=True, loglevel='error')
trio.run(main)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import trio
import tractor


Expand Down Expand Up @@ -50,7 +51,9 @@ async def main():
└─ python -m tractor._child --uid ('spawn_until_0', 'de918e6d ...)
"""
async with tractor.open_nursery() as n:
async with tractor.open_nursery(
debug_mode=True,
) as n:

# spawn both actors
portal = await n.run_in_actor(
Expand All @@ -70,4 +73,4 @@ async def main():


if __name__ == '__main__':
tractor.run(main, debug_mode=True)
trio.run(main)
16 changes: 8 additions & 8 deletions tests/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_root_actor_error(spawn, user_in_out):
before = str(child.before.decode())

# make sure expected logging and error arrives
assert "Attaching to pdb in crashed actor: ('arbiter'" in before
assert "Attaching to pdb in crashed actor: ('root'" in before
assert 'AssertionError' in before

# send user command
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_subactor_error(spawn):
before = str(child.before.decode())

# root actor gets debugger engaged
assert "Attaching to pdb in crashed actor: ('arbiter'" in before
assert "Attaching to pdb in crashed actor: ('root'" in before

# error is a remote error propagated from the subactor
assert "RemoteActorError: ('name_error'" in before
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_multi_subactors(spawn):
child.sendline('q')
child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode())
assert "Attaching to pdb in crashed actor: ('arbiter'" in before
assert "Attaching to pdb in crashed actor: ('root'" in before
assert "RemoteActorError: ('breakpoint_forever'" in before
assert 'bdb.BdbQuit' in before

Expand Down Expand Up @@ -323,7 +323,6 @@ def test_multi_daemon_subactors(spawn, loglevel):
child.expect(pexpect.EOF)



def test_multi_subactors_root_errors(spawn):
"""Multiple subactors, both erroring and breakpointing as well as
a nested subactor erroring.
Expand All @@ -345,7 +344,7 @@ def test_multi_subactors_root_errors(spawn):
before = str(child.before.decode())

# should have come just after priot prompt
assert "Attaching to pdb in crashed actor: ('arbiter'" in before
assert "Attaching to pdb in crashed actor: ('root'" in before
assert "AssertionError" in before

# warnings assert we probably don't need
Expand Down Expand Up @@ -402,7 +401,10 @@ def test_multi_nested_subactors_error_through_nurseries(spawn):
assert "NameError" in before


def test_root_nursery_cancels_before_child_releases_tty_lock(spawn, start_method):
def test_root_nursery_cancels_before_child_releases_tty_lock(
spawn,
start_method
):
"""Test that when the root sends a cancel message before a nested
child has unblocked (which can happen when it has the tty lock and
is engaged in pdb) it is indeed cancelled after exiting the debugger.
Expand All @@ -420,7 +422,6 @@ def test_root_nursery_cancels_before_child_releases_tty_lock(spawn, start_method

child.sendline('c')


for i in range(4):
time.sleep(0.5)
try:
Expand All @@ -440,7 +441,6 @@ def test_root_nursery_cancels_before_child_releases_tty_lock(spawn, start_method
# race conditions on how fast the continue is sent?
break


before = str(child.before.decode())
assert "NameError: name 'doggypants' is not defined" in before

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def main():

async with tractor.open_nursery() as n:

name = 'arbiter'
name = 'root'

if pub_actor == 'streamer':
# start the publisher as a daemon
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_rpc_errors(arb_addr, to_call, testdir):
exposed_mods, funcname, inside_err = to_call
subactor_exposed_mods = []
func_defined = globals().get(funcname, False)
subactor_requests_to = 'arbiter'
subactor_requests_to = 'root'
remote_err = tractor.RemoteActorError

# remote module that fails at import time
Expand Down
4 changes: 2 additions & 2 deletions tractor/_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def open_root_actor(
)
try:
yield actor
# result = await main()

except (Exception, trio.MultiError) as err:
logger.exception("Actor crashed:")
await _debug._maybe_enter_pm(err)
Expand All @@ -185,7 +185,7 @@ def run(
*args,

# runtime kwargs
name: Optional[str] = None,
name: Optional[str] = 'root',
arbiter_addr: Tuple[str, int] = (
_default_arbiter_host,
_default_arbiter_port,
Expand Down
Loading

0 comments on commit 49a02e6

Please sign in to comment.