[Python-bugs-list] [ python-Bugs-822974 ] Telnet.read_until() timeout parameter misleading

SourceForge.net noreply at sourceforge.net
Mon Oct 13 15:25:26 EDT 2003


Bugs item #822974, was opened at 2003-10-13 15:21
Message generated for change (Settings changed) made by mnquinn
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=822974&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
>Priority: 7
Submitted By: Mitchel Quinn (mnquinn)
Assigned to: Nobody/Anonymous (nobody)
Summary: Telnet.read_until() timeout parameter misleading 

Initial Comment:
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()






----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=822974&group_id=5470



More information about the Python-bugs-list mailing list