<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/pexpect.git/doc, branch issue-20</title>
<subtitle>github.com: pexpect/pexpect.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/'/>
<entry>
<title>Issue #20: Strange EOF/TIMEOUT behavior</title>
<updated>2014-05-25T05:34:39+00:00</updated>
<author>
<name>jquast</name>
<email>contact@jeffquast.com</email>
</author>
<published>2014-05-25T05:18:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=11fca676a6b2bb29e6620fe7c096380a7bbce74b'/>
<id>11fca676a6b2bb29e6620fe7c096380a7bbce74b</id>
<content type='text'>
Problem
-------

When running a subprocess that writes a lot of data to stdout, then
exits, it is possible to read all data from stdout, then, when calling
waitpid(2), to be told the subprocess has not yet exited.

pexpect would then call read_nonblocking and block for a full 30
seconds, because there remains no more data on stdout.

Solution
--------

Add new parameter, poll_exit to read_nonblocking so that select(2) is
called at shorter intervals than previously done, but still up until
timeout specified, doing a poll for waitpid(2) at regular intervals.
This ensures that no longer than (default, 0.15) seconds elapse, instead
of the default of 30.

Testing
-------

All existing unit tests, of course. However, as a race condition, it is
not possible to reliably reproduce, it may require anywhere from 1 to 5
minutes of looping to cause it to reproduce, so it was not put into base
tests.

A simple program was authored::

   TIMEOUT=1
   def test_2():
       while True:
           stime = time.time()
           child = pexpect.spawn('ls -lR /dev',
                                 timeout=TIMEOUT)
           child.expect(pexpect.EOF)
           elapsed = time.time() - stime
           print('got eof in {0:0.2f} in pid {1}'
                 .format(elapsed, child.pid))
           assert math.floor(elapsed) &lt; TIMEOUT, elapsed

Without this change, this program will raise an exception after several
dozen runs, hitting the race condition.

With this change, I have been executing this program for several thousand
iterations without failed assertion.

PLEASE CONFER
-------------

@takluyver, with this change, I think we may also delete the
self.__irix_hack and its surrounding hack -- and even the first
self.isalive() check just before this change, for "some systems
such as Solaris" without any penalty in performance.

What do you think?
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem
-------

When running a subprocess that writes a lot of data to stdout, then
exits, it is possible to read all data from stdout, then, when calling
waitpid(2), to be told the subprocess has not yet exited.

pexpect would then call read_nonblocking and block for a full 30
seconds, because there remains no more data on stdout.

Solution
--------

Add new parameter, poll_exit to read_nonblocking so that select(2) is
called at shorter intervals than previously done, but still up until
timeout specified, doing a poll for waitpid(2) at regular intervals.
This ensures that no longer than (default, 0.15) seconds elapse, instead
of the default of 30.

Testing
-------

All existing unit tests, of course. However, as a race condition, it is
not possible to reliably reproduce, it may require anywhere from 1 to 5
minutes of looping to cause it to reproduce, so it was not put into base
tests.

A simple program was authored::

   TIMEOUT=1
   def test_2():
       while True:
           stime = time.time()
           child = pexpect.spawn('ls -lR /dev',
                                 timeout=TIMEOUT)
           child.expect(pexpect.EOF)
           elapsed = time.time() - stime
           print('got eof in {0:0.2f} in pid {1}'
                 .format(elapsed, child.pid))
           assert math.floor(elapsed) &lt; TIMEOUT, elapsed

Without this change, this program will raise an exception after several
dozen runs, hitting the race condition.

With this change, I have been executing this program for several thousand
iterations without failed assertion.

PLEASE CONFER
-------------

@takluyver, with this change, I think we may also delete the
self.__irix_hack and its surrounding hack -- and even the first
self.isalive() check just before this change, for "some systems
such as Solaris" without any penalty in performance.

What do you think?
</pre>
</div>
</content>
</entry>
<entry>
<title>Bump version number for 3.2</title>
<updated>2014-04-15T01:31:30+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-04-15T01:31:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=92debe1aa6e78cc3ee0ecd97eee1d462e313dc1a'/>
<id>92debe1aa6e78cc3ee0ecd97eee1d462e313dc1a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add release notes for 3.2</title>
<updated>2014-04-14T00:45:31+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-04-14T00:45:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=a39f9b4773cf88e7a9eadea84de9a653c72a1553'/>
<id>a39f9b4773cf88e7a9eadea84de9a653c72a1553</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>FAQ.rst: Removed redundant paragraph.</title>
<updated>2014-02-20T15:47:26+00:00</updated>
<author>
<name>Chris Merck</name>
<email>chrismerck@gmail.com</email>
</author>
<published>2014-02-20T15:47:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=81c45250dd8d48c959e242064590567f627f28f7'/>
<id>81c45250dd8d48c959e242064590567f627f28f7</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Document force_password attribute</title>
<updated>2014-01-24T00:02:33+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-01-24T00:02:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=7a8a720b9703bfe34bc0e94f6b339787438f8862'/>
<id>7a8a720b9703bfe34bc0e94f6b339787438f8862</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix documentation of using auto_prompt_reset.</title>
<updated>2014-01-23T23:36:39+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-01-23T23:36:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=bb6ba03af13f8b3adfc64c3986ca522f634befbc'/>
<id>bb6ba03af13f8b3adfc64c3986ca522f634befbc</id>
<content type='text'>
Closes gh-35
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Closes gh-35
</pre>
</div>
</content>
</entry>
<entry>
<title>Prepare for 3.1 release</title>
<updated>2014-01-22T18:44:23+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-01-22T18:44:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=13ec3b0e134159d0168811862a9d7980847ca4e0'/>
<id>13ec3b0e134159d0168811862a9d7980847ca4e0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Squash some Sphinx warnings</title>
<updated>2014-01-22T18:33:47+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2014-01-22T18:33:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=48764e21a8b226b93793bb6582d6b46fa59f8aba'/>
<id>48764e21a8b226b93793bb6582d6b46fa59f8aba</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unhelpful examples</title>
<updated>2013-12-02T21:18:58+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2013-12-02T21:18:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=0c1bcae869c7fd9607f187c828de5eb2a2d7bbe5'/>
<id>0c1bcae869c7fd9607f187c828de5eb2a2d7bbe5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Bump version numbers for 3.0 final release</title>
<updated>2013-11-11T18:13:34+00:00</updated>
<author>
<name>Thomas Kluyver</name>
<email>takowl@gmail.com</email>
</author>
<published>2013-11-11T18:13:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pexpect.git/commit/?id=a3a58027e840a356db2975211b4ff31ee52b10d1'/>
<id>a3a58027e840a356db2975211b4ff31ee52b10d1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
