This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Joel.Lovinger
Recipients Joel.Lovinger, jackdied, r.david.murray
Date 2012-04-12.03:37:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334201826.31.0.280290626077.issue14556@psf.upfronthosting.co.za>
In-reply-to
Content
Quick response!

Based on review of Telnet.expect in Python 2.4.3 and Python 2.7.1/2.7.3.  

In Python 2.4.3 the timeout is passed unmodified on each loop iteration to the underlying select to get more data for a potential match. Iteration only ends on EOF, select timeout with no rx, or match. A timeout=0 received data, without blocking, until no more data or a match was found. 

Unfortunately this implementation can extend the timeout indeterminately if the connection consistently has data for each select but no match is made.

Imagine with timeout=10 and a byte coming in every 5 seconds. Select will always succeed and continue to iterate.

Could even happen with timeout=0 if match processing takes long enough for each iteration (high system load, long input buffer, complicated reg ex, etc).

Python 2.7.1 keeps track of overall elapsed time in Telnet.expect itself and explicitly drops out when it exceeds the timeout. Further passes (timeout-elapsed) as the timeout to select.

Works to ensure an expect never exceeds its timeout, but breaks the case where timeout=0 can read non-blocking to find a match.
History
Date User Action Args
2012-04-12 03:37:06Joel.Lovingersetrecipients: + Joel.Lovinger, jackdied, r.david.murray
2012-04-12 03:37:06Joel.Lovingersetmessageid: <1334201826.31.0.280290626077.issue14556@psf.upfronthosting.co.za>
2012-04-12 03:37:05Joel.Lovingerlinkissue14556 messages
2012-04-12 03:37:05Joel.Lovingercreate