Joel Lovinger <jlovin...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14556>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to