Skip to content

Handle asyncio.CancelledError in SSH session interaction#2072

Open
dnyanesh1011 wants to merge 3 commits into
prompt-toolkit:mainfrom
dnyanesh1011:fix-ssh-cancelled-error
Open

Handle asyncio.CancelledError in SSH session interaction#2072
dnyanesh1011 wants to merge 3 commits into
prompt-toolkit:mainfrom
dnyanesh1011:fix-ssh-cancelled-error

Conversation

@dnyanesh1011
Copy link
Copy Markdown

Fixes noisy traceback propagation during SSH session cancellation.

Currently _interact() catches BaseException, which also captures asyncio.CancelledError. In modern asyncio versions (especially Python 3.11+ / 3.13), CancelledError is expected control-flow during task shutdown and should not be treated as an application error.

This change:

  • handles asyncio.CancelledError explicitly
  • keeps normal application exceptions visible
  • avoids traceback spam during SSH disconnect/session cancellation
  • improves cancellation behavior when pressing Ctrl-C during the asyncssh example progress demo

Related issue: #1991

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.

1 participant