469,277 Members | 2,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

How to flush pexpect spawn class buffer for subsequent expect calls??

Python pexpect module's "spawn" class lets you interact with a spawned child process.

As per its official API documentation on http://pexpect.sourceforge.net/pexpect.html

The maxread attribute sets the read buffer size. This is maximum number
of bytes that Pexpect will try to read from a TTY at one time. Setting
the maxread size to 1 will turn off buffering. Setting the maxread
value higher may help performance in cases where large amounts of
output are read back from the child. This feature is useful in
conjunction with searchwindowsize.

The searchwindowsize attribute sets the how far back in the incomming
seach buffer Pexpect will search for pattern matches. Every time
Pexpect reads some data from the child it will append the data to the
incomming buffer. The default is to search from the beginning of the
imcomming buffer each time new data is read from the child. But this is
very inefficient if you are running a command that generates a large
amount of data where you want to match The searchwindowsize does not
effect the size of the incomming data buffer. You will still have
access to the full buffer after expect() returns.
************************************************** **

Now my problem lies in that fact that executing "expect()" function more than once just keep on appending to the spawn class buffer inspite of the fact that I have set "maxread" to 1 and "searchwindowsize" to 0 in the spawn class constructor.

child = pexpect.spawn(login_string, timeout=20,logfile=None,maxread=1,searchwindowsize =0)

Due to this, my program logic is not working correctly.
Can anyone please help me out quickly.....???


pls posts replies to ***********

-Thanks in advance,
Jul 15 '11 #1
0 1775

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Michael Surette | last post: by
1 post views Thread by H Branyan | last post: by
5 posts views Thread by half.italian | last post: by
2 posts views Thread by Jim Matheson | last post: by
4 posts views Thread by Michel Rouzic | last post: by
1 post views Thread by Anh Khuong | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.