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 padded
Recipients
Date 2005-08-04.15:47:52
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
So, I looked through the read_until code and there is
no provision to jump out of the function and return
whatever its got so far if it reaches the timeout. 
This is a problem and so far I couldn't see anyone
giving people a clear reason why this is happening.  So
I added a few snippets of code to handle the timeout. 
So if you pass a timeout value along with the
read_until, it will timeout after that many seconds
(roughly). Here's my snippet of the code:
    def read_until(self, match, timeout=None):
        """Read until a given string is encountered or
until timeout.

        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.
        Modified such that the timeout feature DOES
timeout when it
        needs to.

        """
        n = len(match)
        self.process_rawq()
        i = self.cookedq.find(match)
        if i >= 0:
            i = i+n
            buf = self.cookedq[:i]
            self.cookedq = self.cookedq[i:]
            return buf
        s_reply = ([self], [], [])
        s_args = s_reply
        if timeout is not None:
            s_args = s_args + (timeout,)
        timeoutcounter=0 #added this, simple counter
for number of times we've slept
        while not self.eof and 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
            
            if timeout is not None:#this will handle
the timeout.
                time.sleep(1)
                timeoutcounter+=1
                if(timeoutcounter>timeout):
                  buf=self.cookedq
                  self.cookedq = ""
                  return buf
        return self.read_very_lazy()
History
Date User Action Args
2008-01-20 09:58:05adminlinkissue1252001 messages
2008-01-20 09:58:05admincreate