forked from goodboy/tractor
1
0
Fork 0

Tweaks to debugger examples

Light stuff like comments, typing, and a couple API usage updates.
runtime_to_msgspec
Tyler Goodlet 2024-05-28 09:22:59 -04:00
parent eee4c61b51
commit 27fd96729a
6 changed files with 36 additions and 13 deletions

View File

@ -4,9 +4,15 @@ import trio
async def breakpoint_forever():
"Indefinitely re-enter debugger in child actor."
try:
while True:
yield 'yo'
await tractor.breakpoint()
except BaseException:
tractor.log.get_console_log().exception(
'Cancelled while trying to enter pause point!'
)
raise
async def name_error():
@ -19,7 +25,7 @@ async def main():
"""
async with tractor.open_nursery(
debug_mode=True,
loglevel='error',
loglevel='cancel',
) as n:
p0 = await n.start_actor('bp_forever', enable_modules=[__name__])

View File

@ -45,6 +45,7 @@ async def spawn_until(depth=0):
)
# TODO: notes on the new boxed-relayed errors through proxy actors
async def main():
"""The main ``tractor`` routine.

View File

@ -23,5 +23,6 @@ async def main():
n.start_soon(debug_actor.run, die)
n.start_soon(crash_boi.run, die)
if __name__ == '__main__':
trio.run(main)

View File

@ -2,10 +2,13 @@ import trio
import tractor
async def main():
async def main(
registry_addrs: tuple[str, int]|None = None
):
async with tractor.open_root_actor(
debug_mode=True,
# loglevel='runtime',
):
while True:
await tractor.breakpoint()

View File

@ -3,16 +3,26 @@ import tractor
async def name_error():
getattr(doggypants)
getattr(doggypants) # noqa (on purpose)
async def main():
async with tractor.open_nursery(
debug_mode=True,
) as n:
# loglevel='transport',
) as an:
portal = await n.run_in_actor(name_error)
await portal.result()
# TODO: ideally the REPL arrives at this frame in the parent,
# ABOVE the @api_frame of `Portal.run_in_actor()` (which
# should eventually not even be a portal method ... XD)
# await tractor.pause()
p: tractor.Portal = await an.run_in_actor(name_error)
# with this style, should raise on this line
await p.result()
# with this alt style should raise at `open_nusery()`
# return await p.result()
if __name__ == '__main__':

View File

@ -7,7 +7,7 @@ def sync_pause(
error: bool = False,
):
if use_builtin:
breakpoint()
breakpoint(hide_tb=False)
else:
tractor.pause_from_sync()
@ -20,18 +20,20 @@ def sync_pause(
async def start_n_sync_pause(
ctx: tractor.Context,
):
# sync to requesting peer
actor: tractor.Actor = tractor.current_actor()
# sync to parent-side task
await ctx.started()
actor: tractor.Actor = tractor.current_actor()
print(f'entering SYNC PAUSE in {actor.uid}')
sync_pause()
print(f'back from SYNC PAUSE in {actor.uid}')
async def main() -> None:
async with tractor.open_nursery(
# NOTE: required for pausing from sync funcs
maybe_enable_greenback=True,
debug_mode=True,
) as an: