No documented way to check that channel has closed #621
SSH sends exit status before the stdout data, and there is no documented way to properly check that the channel has actually finished.
SSH can have exit status sent before stdout data. The typical approach in real-time streaming is to check if channel is recv_ready, recv_stderr_ready or exit_status_ready. There are no other documented ways to check the channel has actually finished.
With this script iterated infinitely, it fails on an attempt number 40-120 (randomly):
The hexdump looks like this (note the timing in seconds!):
If you are unlucky enough to start your 1st iteration of the while cycle when the exit status is already there (can be simulated with time.sleep), you do not even enter the cycle's body, and go straight to recv_exit_status().
But there is undocumented field channel.closed, which can be used to fix this issue. This line works fine:
Please make it documented, or add some other way to check that the channel has actually finished.
The text was updated successfully, but these errors were encountered:
Thanks for the thorough report! I don't know offhand what the status of
Will take a look during next release cycle.
Seems the practice has simply not been to document any class parameters whatsoever. Sphinx supports doing so, so I'm experimenting with slapping basic descriptions on what I perceive as the most useful/effectively-public attributes, including
Ideally I'd go around and do this to all classes but don't have time at the moment; will probably still merge for Channel for now.