I am using the below code:
import paramiko
def runSshCmd(hostname, username, password, cmd, timeout=None):
client = paramiko.SSHClient()
It use to happen when there is no data in stdout or there is a line without eol (i.e. in a read statement inside a sh script). Try setting 'get_pty=True', then reading only the bytes in stdout. To avoid infinite loops, it'd be a good idea setting a timeout and a sleep in spite of the continue statement:
stdin, stdout, stderr = ssh.exec_command("your-command",get_pty=True)
stdout.flush()
nbytes = 0
while (len(stdout.channel.in_buffer)==0):
continue
nbytes=len(stdout.channel.in_buffer)
print(nbytes)
stdout.read(nbytes)