Paramiko ssh die/hang with big output

后端 未结 2 971
再見小時候
再見小時候 2020-12-18 09:09

I try to backup a server using Paramiko and ssh to call a tar command. When there is a limited number of files, all works well but when it\'s a big folder, the

相关标签:
2条回答
  • 2020-12-18 09:43

    read data before check exit status

    channel.recv_exit_status() hanging

    0 讨论(0)
  • 2020-12-18 09:49

    If the ls -R prints lots of error output (what is likely if the current user is not root => does not have access to all folders), your code deadlocks eventually.

    It's because, the output buffer of the error stream eventually fills, so the ls stops working, waiting for you to read the stream (empty the buffer).

    While you wait for the regular output stream to finish, what it never does, as the ls waits for you to read the error stream, what you never do.

    You have to read both streams in parallel.

    Or even easier, use the Channel.set_combine_stderr to merge both streams to one.

    0 讨论(0)
提交回复
热议问题