forked from goodboy/tractor
1
0
Fork 0

Move debugger locking to new stream api

stream_contexts
Tyler Goodlet 2021-04-28 08:40:22 -04:00
parent 80c96cab01
commit 3e19fd311b
1 changed files with 10 additions and 12 deletions

View File

@ -182,24 +182,22 @@ def _breakpoint(debug_func) -> Awaitable[None]:
_debugger_request_cs = cs _debugger_request_cs = cs
try: try:
async with get_root() as portal: async with get_root() as portal:
with trio.fail_after(.5): async with portal.open_stream_from(
stream = await portal.run(
tractor._debug._hijack_stdin_relay_to_child, tractor._debug._hijack_stdin_relay_to_child,
subactor_uid=actor.uid, subactor_uid=actor.uid,
) ) as stream:
async with aclosing(stream):
# block until first yield above # block until first yield above
async for val in stream: async for val in stream:
assert val == 'Locked' assert val == 'Locked'
task_status.started() task_status.started()
# with trio.CancelScope(shield=True): # with trio.CancelScope(shield=True):
await do_unlock.wait() await do_unlock.wait()
# trigger cancellation of remote stream # trigger cancellation of remote stream
break break
finally: finally:
log.debug(f"Exiting debugger for actor {actor}") log.debug(f"Exiting debugger for actor {actor}")
global _in_debug global _in_debug