From a8406c86263bfc3f4a6fb394a304df3a0aca694d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 15 Oct 2020 23:15:20 -0400 Subject: [PATCH] Toss in another tests with daemon subactors --- examples/debugging/multi_daemon_subactors.py | 31 ++++++++++++++++++++ tests/test_debugger.py | 28 ++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 examples/debugging/multi_daemon_subactors.py diff --git a/examples/debugging/multi_daemon_subactors.py b/examples/debugging/multi_daemon_subactors.py new file mode 100644 index 0000000..b37f47a --- /dev/null +++ b/examples/debugging/multi_daemon_subactors.py @@ -0,0 +1,31 @@ +import tractor +import trio + + +async def breakpoint_forever(): + "Indefinitely re-enter debugger in child actor." + while True: + yield 'yo' + await tractor.breakpoint() + + +async def name_error(): + "Raise a ``NameError``" + getattr(doggypants) + + +async def main(): + """Test breakpoint in a streaming actor. + """ + async with tractor.open_nursery() as n: + + p0 = await n.start_actor('bp_forever', rpc_module_paths=[__name__]) + p1 = await n.start_actor('name_error', rpc_module_paths=[__name__]) + + # retreive results + stream = await p0.run(__name__, 'breakpoint_forever') + await p1.run(__name__, 'name_error') + + +if __name__ == '__main__': + tractor.run(main, debug_mode=True, loglevel='error') diff --git a/tests/test_debugger.py b/tests/test_debugger.py index 5ea4f71..fc94b6f 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -282,6 +282,34 @@ def test_multi_subactors(spawn): assert 'bdb.BdbQuit' in before +def test_multi_daemon_subactors(spawn): + """Multiple daemon subactors, both erroring and breakpointing within a + stream. + """ + child = spawn('multi_daemon_subactors') + + child.expect(r"\(Pdb\+\+\)") + + before = str(child.before.decode()) + assert "Attaching pdb to actor: ('bp_forever'" in before + + child.sendline('c') + + # first name_error failure + child.expect(r"\(Pdb\+\+\)") + before = str(child.before.decode()) + assert "NameError" in before + + child.sendline('c') + + child.expect(r"\(Pdb\+\+\)") + before = str(child.before.decode()) + assert "tractor._exceptions.RemoteActorError: ('name_error'" in before + + child.sendline('c') + child.expect(pexpect.EOF) + + def test_multi_subactors_root_errors(spawn): """Multiple subactors, both erroring and breakpointing as well as a nested subactor erroring.