Avoid boolean tests of debugger `trio.Event` handles
On `trio` 0.34, boolean tests of `trio.Event` raise. Debugger setup/release, TTY-lock diagnostics and the RPC cancellation path used truthiness to check whether optional event handles existed, raising `NotImplementedError` instead of entering or leaving the REPL and waiting for its release. Use explicit `is None`/`is not None` checks for those five sites. Keep `.is_set()` for the actual release-state decision and retain the existing waits: an allocated pending event is not an absent handle, nor does its existence mean it has been signaled. Keep the debug-request comment beside its lock-release check. (this patch was generated in some part by `opencode` using `gpt-6.1-sol` (`openai`))ipc_fault_regressions
parent
51330af072
commit
025cbe0db0
|
|
@ -285,7 +285,7 @@ async def _pause(
|
|||
# the `PdbREPL`.
|
||||
repl_task: Thread|Task|None = DebugStatus.repl_task
|
||||
if (
|
||||
not DebugStatus.repl_release
|
||||
DebugStatus.repl_release is None
|
||||
or
|
||||
DebugStatus.repl_release.is_set()
|
||||
):
|
||||
|
|
@ -849,7 +849,7 @@ async def _pause_from_bg_root_thread(
|
|||
stats: trio.LockStatistics= lock.statistics()
|
||||
assert stats.owner is task
|
||||
assert Lock._owned_by_root
|
||||
assert DebugStatus.repl_release
|
||||
assert DebugStatus.repl_release is not None
|
||||
|
||||
# TODO: do we actually need this?
|
||||
# originally i was trying to solve wy this was
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class Lock:
|
|||
f'|_ .ctx_in_debug: {cls.ctx_in_debug}\n'
|
||||
f'|_ .req_handler_finished: {req}\n'
|
||||
)
|
||||
if req:
|
||||
if req is not None:
|
||||
req_stats: trio.EventStatistics = req.statistics()
|
||||
fields += f' {req_stats}\n'
|
||||
|
||||
|
|
@ -288,7 +288,8 @@ class Lock:
|
|||
)
|
||||
|
||||
elif (
|
||||
req_handler_finished # new IPC ctx debug request active
|
||||
# new IPC ctx debug request active
|
||||
req_handler_finished is not None
|
||||
and
|
||||
lock.locked() # someone has the lock
|
||||
):
|
||||
|
|
|
|||
|
|
@ -1137,7 +1137,7 @@ async def process_messages(
|
|||
# runtime cancellation if this actor is
|
||||
# currently in debug mode!
|
||||
pdb_complete: trio.Event|None = debug.DebugStatus.repl_release
|
||||
if pdb_complete:
|
||||
if pdb_complete is not None:
|
||||
await pdb_complete.wait()
|
||||
|
||||
# Either of `Actor.cancel()`/`.cancel_soon()`
|
||||
|
|
|
|||
Loading…
Reference in New Issue