Timeout exceeded in read_nonblocking

在写pxssh登录远程主机的代码,遇到pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(),依靠万能google找到答案


I don’t know if anyone ever got back to you with a fix, but for me the fix was really simple.

I just added a self.sendline() and a time.sleep(0.5) right before the first read_nonblocking() call within synch_original_prompt

The reason is that you have to have stuff in the buffer in order to read it. In the case that they programmed for originally,**something** exists in their prompt (probably a space) after the $ or #. In my case (and probably yours) the last thing on the prompt **is** the $ or #, causing the buffer to be non-existent when the first read_nonblocking() happens. So all we do is put something there before the read.

Why not just get rid of the first read since it is just “clearing the buffer” anyway? Because then, although it would now work for us, it would no longer work for the original programmers.

– Jinno

One Response to “Timeout exceeded in read_nonblocking”

  1. stamhe说道:

    pexpect.spawn(cmd, “”, timeout=86400)

Post a Comment