Note that there are some explanatory texts on larger screens.

plurals
  1. POpexpect can't pass input over 1024 chars?
    primarykey
    data
    text
    <p>I'm currently passing some input to a process with pexpect with the following code:</p> <pre><code>p = pexpect.spawn('cat', timeout=5.0 ) p.maxread = 5000 p.setecho(False) # prevent the process from echoing stdin back to us INPUT_LEN = 1024 p.sendline('a'*INPUT_LEN) print p.readline() # pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). </code></pre> <p>When INPUT_LEN &lt; 1024, everything works fine, but <strong>for >= 1024 characters, the process does not receive the full input</strong>, causing raising a "pexpect.TIMEOUT" error on p.readline().</p> <p>I've tried splitting my input into pieces smaller than 1024 characters, but this has the same issue:</p> <pre><code>p = pexpect.spawn('cat', timeout=5.0 ) p.maxread = 5000 p.setecho(False) INPUT_LEN = 1024 p.send('a'*1000) p.sendline('a'*(INPUT_LEN-1000)) print p.readline() # pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). </code></pre> <p>Does anyone know how to make pexpect work with inputs over 1024 characters? I tried looking at the source, but it just seems to be calling os.write(...).</p> <p>(As a side note, I've noticed the same truncation error occurs when I run "cat" from a shell and attempt to paste in >=1024 characters with "Cmd+V". However, everything works fine if I run "pbpaste | cat" .)</p> <p>Thanks!</p> <p><strong>Update:</strong> The call to "os.write()" returns 1025, indicating a successful write, but os.read() returns "\x07" (the single character BEL), and then hangs on the next call, resulting in the timeout.</p> <p>Dividing the os.write() call into two sub-1024 byte write()s, separated by a call to os.fsync(), does not change anything.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload