Skip to content

examples/ssh /asyncssh-server.py a CTRL-C during the progress kills also the Server #1991

Open
@gierig1977

Description

@gierig1977

Starting to Discover async, AsyncSSH and as well that very nice prompt_toolkit

Demo (examples/ssh /asyncssh-server.py) seems perfect as "StartPoint" to discover.
Demo is running fine.
But when you Press "CTRL-C" During the progress bar demo it will also kill the Server.
(as well on the client Side)

latest Trackack:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/gierig/Library/Mobile Documents/com~apple~CloudDocs/Documents/code/myBBS/test.py", line 117, in main
    await asyncio.Future()
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 123, in run
    raise KeyboardInterrupt()
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/gierig/Library/Mobile Documents/com~apple~CloudDocs/Documents/code/myBBS/lib/python3.13/site-packages/prompt_toolkit/contrib/ssh/server.py", line 103, in _interact
    await self.interact(self)
  File "/Users/gierig/Library/Mobile Documents/com~apple~CloudDocs/Documents/code/myBBS/test.py", line 77, in interact
    await asyncio.sleep(0.1)
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/tasks.py", line 718, in sleep
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError
INFO:asyncssh:[conn=0, chan=0] Closing channel
INFO:asyncssh:[conn=0, chan=0] Received channel close
DEBUG:asyncssh:[conn=0] Received disconnect: disconnected by user (11)
INFO:asyncssh:[conn=0, chan=0] Channel closed
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/gierig/Library/Mobile Documents/com~apple~CloudDocs/Documents/code/myBBS/test.py", line 117, in main
    await asyncio.Future()
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/gierig/Library/Mobile Documents/com~apple~CloudDocs/Documents/code/myBBS/test.py", line 121, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 123, in run
    raise KeyboardInterrupt()
KeyboardInterrupt

Wonder that a KeyboardInterrupt is rise up till the Server Process.. t should max kill the Ssh Session and not the Server ?

Version seem latest

 pip list
Package           Version
----------------- -------
asyncssh          2.21.0
cffi              1.17.1
cryptography      44.0.3
pip               25.1.1
prompt_toolkit    3.0.51
pycparser         2.22
Pygments          2.19.1
typing_extensions 4.13.2
wcwidth           0.2.13

Not sure where to start to fix that...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions