Skip to content

fix: keyboard interrupt trace#304

Open
lilyydu wants to merge 4 commits intomainfrom
lilyydu/fix-keyboard-interrupt
Open

fix: keyboard interrupt trace#304
lilyydu wants to merge 4 commits intomainfrom
lilyydu/fix-keyboard-interrupt

Conversation

@lilyydu
Copy link
Collaborator

@lilyydu lilyydu commented Mar 4, 2026

before, when you do Ctrl-C after running the sample via the terminal, it would throw a giant trace:

image

now, with this update:

image

Copilot AI review requested due to automatic review settings March 4, 2026 23:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds graceful handling of KeyboardInterrupt (via asyncio.CancelledError) during app startup in the Teams SDK. Previously, pressing Ctrl+C while running a sample app would produce a large, noisy traceback. Now, the cancellation is caught, a clean shutdown message is logged, and stop() is called for cleanup.

Changes:

  • Added an except clause to catch asyncio.CancelledError and KeyboardInterrupt in App.start(), logging a shutdown message and calling self.stop() instead of letting the exception propagate with a full traceback.

@lilyydu lilyydu changed the title fix: keyboard interrupt traace fix: keyboard interrupt trace Mar 4, 2026
except (asyncio.CancelledError, KeyboardInterrupt):
self.log.info("Teams app shutting down")
try:
for plugin in reversed(self.plugins):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, could you run self.stop()?

Copy link
Collaborator Author

@lilyydu lilyydu Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it as stop initially and then copilot left this comment - #304 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is our main concern tho:

at the top of stop - we immediately return if the app is not running. if cancellation happens before on_http_ready() fires , self._running is still False, so self.stop() would return without cleaning up anything

it is very similiar logic tho, so I could just extract the common code into a single helper

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.

4 participants