Comment all `.pause(shield=True)` attempts again, need to solve cancel scope `.__exit__()` frame hiding issue..

multihomed
Tyler Goodlet 2023-10-10 09:55:11 -04:00
parent 575a24adf1
commit 6d951c526a
1 changed files with 128 additions and 116 deletions

View File

@ -631,6 +631,7 @@ def _set_trace(
# no f!#$&* idea, but when we're in async land # no f!#$&* idea, but when we're in async land
# we need 2x frames up? # we need 2x frames up?
frame = frame.f_back frame = frame.f_back
# frame = frame.f_back
# if shield: # if shield:
# frame = frame.f_back # frame = frame.f_back
@ -646,17 +647,19 @@ def _set_trace(
# undo_ # undo_
async def pause( async def pause(
debug_func: Callable = _set_trace, debug_func: Callable = _set_trace,
release_lock_signal: trio.Event | None = None, release_lock_signal: trio.Event | None = None,
# allow caller to pause despite task cancellation, # TODO: allow caller to pause despite task cancellation,
# exactly the same as wrapping with: # exactly the same as wrapping with:
# with CancelScope(shield=True): # with CancelScope(shield=True):
# await pause() # await pause()
shield: bool = False, # => the REMAINING ISSUE is that the scope's .__exit__() frame
# is always show in the debugger on entry.. and there seems to
# be no way to override it?..
# shield: bool = False,
# TODO: # TODO:
# shield: bool = False # shield: bool = False
@ -689,13 +692,22 @@ async def pause(
): ):
Lock.local_pdb_complete = trio.Event() Lock.local_pdb_complete = trio.Event()
if shield: # if shield:
debug_func = partial( debug_func = partial(
debug_func, debug_func,
shield=shield, # shield=shield,
) )
with trio.CancelScope(shield=shield): # def _exit(self, *args, **kwargs):
# __tracebackhide__: bool = True
# super().__exit__(*args, **kwargs)
# trio.CancelScope.__exit__.__tracebackhide__ = True
# import types
# with trio.CancelScope(shield=shield) as cs:
# cs.__exit__ = types.MethodType(_exit, cs)
# cs.__exit__.__tracebackhide__ = True
# TODO: need a more robust check for the "root" actor # TODO: need a more robust check for the "root" actor
if ( if (