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.

classification
Title: Telnet.read_until() timeout parameter misleading
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: johahn, loewis, mnquinn
Priority: high Keywords:

Created on 2003-10-13 19:21 by mnquinn, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (3)
msg18618 - (view) Author: Mitchel Quinn (mnquinn) Date: 2003-10-13 19:21
Telnet.read_until(str,timeout) documentation reads as
follows:
Read until a given string, expected, is encountered or
until timeout seconds have passed.

When no match is found, return whatever is available
instead, possibly the empty string. Raise EOFError if
the connection is closed and no cooked data is available. 

However, the method does not behave in this manner. The
method will only return if the call to select() on the
socket is blocked for longer than the specified
timeout. If there is a steady stream of data available,
and it does not contain the specified string, this
method will _NEVER_ return.

A possible solution would be to subtract the elapsed
time from the given timeout each time through the while
loop.

Here's a snippet of the code from telnetlib.py
read_until():

        if timeout is not None:
            s_args = s_args + (timeout,)
        while not self.eof and apply(select.select,
s_args) == s_reply:
            i = max(0, len(self.cookedq)-n)
            self.fill_rawq()
            self.process_rawq()
            i = self.cookedq.find(match, i)
            if i >= 0:
                i = i+n
                buf = self.cookedq[:i]
                self.cookedq = self.cookedq[i:]
                return buf
        return self.read_very_lazy()




msg18619 - (view) Author: Johan M. Hahn (johahn) Date: 2003-10-17 10:31
Logged In: YES 
user_id=887415

I confirm everything Mitchel wrote + I have submitted a patch 
for this:


http://sourceforge.net/tracker/index.php?
func=detail&aid=825417&group_id=5470&atid=305470




...johahn
msg18620 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-07-03 13:03
Logged In: YES 
user_id=21627

This is fixed with said patch.
History
Date User Action Args
2022-04-10 16:11:43adminsetgithub: 39401
2003-10-13 19:21:23mnquinncreate