-
Notifications
You must be signed in to change notification settings - Fork 70
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
while size > 0 nevers exits #70
Comments
Because the first read is finished and the second read is always blocked, it's better to check if it's done again, such as checking the prompt. |
Or you can set session to non-block, but can't be sure to receive all data |
Hi there, Thanks for the interest. This is not an issue with the library.
The channel should be closed before trying to read again if no more commands will be sent to it. Alternatively use If all the output needed has already been received, why is the client code trying to read more data without doing anything on the channel? There will obviously be no output from it unless something is executed first. There is functionality in the libssh2 API to check if output is available - see See example for use of |
Cheers. That clears things up. I did it this way following an online example that is obviously wrong. I'm also trying to build in some simple error checking for an automated unsupervised script. i.e.
Do again for next lot of data etc Otherwise no returned data (as some issue occurred or its wrong) the script is stuck in an infinite loop (unless there's a timeout) An infinite loop is never a good thing without some sort of exit plan. The example you have posted is also doing this:
|
The example is using The example as present in the repo is correct for what it does, as above. |
Im trying to follow the online examples and if I run the following the loop never exits.
If I remove the while loop all is good. If the read() call is waiting then whats the point of the while.
Similar code works fine same server with paramiko using "while not channel.recv_ready() :" etc.
Is this a bug or by design
Code:
Bug reports
Expected behaviour: Exit the while loop
Actual behaviour: Didn't Exit
The text was updated successfully, but these errors were encountered: