I use Paramiko to issue several commands and collect results for further analysis. From time to time, the results of the first team are marked as fully returned in time and end on the output for the second team.
I am trying to use recv_ready to account for this, but it does not work, so I assume that I am doing something wrong. Here is the relevant code:
pause = 1 def issue_command(chan, pause, cmd): # send commands and return results chan.send(cmd + '\n') while not chan.recv_ready(): time.sleep(pause) data = chan.recv(99999) ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) chan = ssh.connect(host, port=22, username=username, password=password, timeout=3,) resp1 = issue_command(chan, pause, cmd1) resp2 = issue_command(chan, pause, cmd2)
The output for these teams is relatively small (a few suggestions). Increasing the pause is likely to solve the problem, but is not an ideal solution.
Any suggestions or recommendations would be appreciated.
source share