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=True on loop.subprocess_exec to prevent signals from propagating.
|
_, tunnel = await loop.subprocess_exec(_ProxyCommandTunnel, *command) |
-
The context manager of SSHConnection does 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 a process_exited method in _ProxyCommandTunnel, but I am unsure on how to proceed from there as the connection cleanup logic seems quite complex.