-
Notifications
You must be signed in to change notification settings - Fork 168
Description
Hi,
First of all thank you for writing this library, it has been incredibly useful to me so far.
I am currently running into a few issues while connecting to a server using the ProxyCommand option:
-
When sending a SIGINT to the Python process, the signal is also received by the proxy command process and causes it to terminate. This prevents any further communication and thus the graceful termination of the Python program. Here is a short example to reproduce this; pressing Ctrl+C leads to an unexpected "SSH connection closed" exception.
async with asyncssh.connect("...") as conn: print("Connected") try: await asyncio.Future() finally: await conn.run("echo Hello")
I believe this can be fixed quite easily by setting
start_new_session=Trueonloop.subprocess_execto prevent signals from propagating.
asyncssh/asyncssh/connection.py
Line 410 in c7bc3aa
_, tunnel = await loop.subprocess_exec(_ProxyCommandTunnel, *command) -
The context manager of
SSHConnectiondoes not wait for the proxy command process to terminate before exiting. This causes a leak of the process which is reported as a warning when the event loop closes: "Loop [...] that handles pid xxx is closed". It should be possible to wait for process termination by adding aprocess_exitedmethod in_ProxyCommandTunnel, but I am unsure on how to proceed from there as the connection cleanup logic seems quite complex.