Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gierig1977 opened this issue May 8, 2025 · 0 comments

Comments

@gierig1977
Copy link

gierig1977 commented May 8, 2025

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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...

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

No branches or pull requests

1 participant