diff --git a/src/prompt_toolkit/contrib/ssh/server.py b/src/prompt_toolkit/contrib/ssh/server.py index 7ce70f781..92101700b 100644 --- a/src/prompt_toolkit/contrib/ssh/server.py +++ b/src/prompt_toolkit/contrib/ssh/server.py @@ -100,10 +100,17 @@ async def _interact(self) -> None: with create_pipe_input() as self._input: with create_app_session(input=self._input, output=self._output) as session: self.app_session = session + try: await self.interact(self) - except BaseException: + + except asyncio.CancelledError: + # Expected during disconnect/shutdown. + pass + + except Exception: traceback.print_exc() + finally: # Close the connection. self._chan.close()