Skip to content

Add message with debugging info to Cancelled#3256

Merged
jakkdl merged 20 commits into
python-trio:mainfrom
jakkdl:cancel_reason
May 15, 2025
Merged

Add message with debugging info to Cancelled#3256
jakkdl merged 20 commits into
python-trio:mainfrom
jakkdl:cancel_reason

Conversation

@jakkdl
Copy link
Copy Markdown
Member

@jakkdl jakkdl commented Apr 22, 2025

fixes #3232 by adding a CancelReason that's tracked by both CancelScope and CancelStatus and then used when constructing a Cancelled to be raised.

Remaining stuff:

  • I'm not 100% sure that both CancelScope and CancelStatus needs to have a CancelReason member - initially only CancelStatus had it but that wasn't enough, but I haven't tried to see if I can get away with only CancelScope having it.
    • It's now only tracked in CancelScope
  • I also found a bug as I was reviewing and adding a final test, where manually setting cs.deadline=-inf and then checkpointing somehow ends up as an explicit cancelled.
  • from_thread_check_cancelled needs some special handling
    • I managed to fix this.. but in a way that created cyclic garbage. So need a better fix

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add exception message for easier debugging with Cancelled

6 participants