Conversation
There was a problem hiding this comment.
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
exceptclause to catchasyncio.CancelledErrorandKeyboardInterruptinApp.start(), logging a shutdown message and callingself.stop()instead of letting the exception propagate with a full traceback.
| except (asyncio.CancelledError, KeyboardInterrupt): | ||
| self.log.info("Teams app shutting down") | ||
| try: | ||
| for plugin in reversed(self.plugins): |
There was a problem hiding this comment.
hm, could you run self.stop()?
There was a problem hiding this comment.
I had it as stop initially and then copilot left this comment - #304 (comment)
There was a problem hiding this comment.
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
before, when you do
Ctrl-Cafter running the sample via the terminal, it would throw a giant trace:now, with this update: