I'm running into an odd issue using paramiko and its interactive shell functionality. I have a session open with 2 channels, (channel 0 is sending commands to a daemon, channel 1 is running the daemon).
My goal is to get all the output from channel 1 (the daemon output), and paramiko is doing that to an extent. My issue is after an indeterminant amount of time (5 minutes to 3 hours) paramiko suddenly stops receiving input and just hangs.
I have combined stderr to stdout so I only need to read off of one stream (found at Paramiko ssh die/hang with big output). I've also implemented the recv_ready to prevent premature reads from the socket:
# finished is a bool that is set else where in the code, I'm looking for a particular string
while not finished:
if not self._daemon_channel.recv_ready():
time.sleep(1)
msg = self._daemon_channel.recv(1024)
However, as stated above it randomly stops reading after some time. Using the debugger, I see that the code is getting stuck on paramiko's read_all function in packet.py. To me it looks like this read_all function is trying to read from the underlying socket, but there is no data in it so the program freezes up.
Any ideas would be appreciated.
EDIT: I found that running my code outside of my IDE (Pycharm) seems to have alleviated the issue. Will make another edit if this was just a coincidence, but it ran for a solid 8 hours without hanging.