Problems with read_eager and Telnet

Robi roberto.inzerillo at gmail.com
Mon Feb 28 12:48:46 EST 2011


On 28 Feb, 18:35, Jack Diederich <jackd... at gmail.com> wrote:
> On Mon, Feb 28, 2011 at 12:13 PM, Roberto Inzerillo
>
> <roberto.inzeri... at gmail.com> wrote:
> > Yes. read_eager() will never actually read from the socket, if it has
>
> >> any data it has already read & processed it will return those.  If you
> >> call it enough times it will just start returning empty strings
> >> because it never asks the socket to read & wait for new data.
>
> > Can you point me to a pratical usage example of read_eager()? Maybe that
> > will help me in making all this clear. I'm still very fuzzy about the socket
> > and the processing stuff.
>
> > I'm still convinced I cannot use read_until() in my project and I'm
> > determined in looking into the read_eager(), maybe that will be of any help
> > if carefully used.
>
> If you always want to see the response you have to use read_until().
> All the other read_* methods don't guarantee you will get the text you
> want because they don't wait for the other end of the connection to
> have actually sent the data.  It's a bummer, but if the server hasn't
> returned the data there is nothing magic that telnetlib can do to make
> it true.

Well, you see, I could prefetch some usefull data in a spare cycle,
maybe this way I could "fake" almost-realtime ... I don't know, I'm
just guessing here.

Fact is, in my case, when I do a 100 write/read cycles in a second
with telnet.write() followed by telnet.read-eager(), I see I get all
those 100 things done properly, that means, both client and server are
doing it right, there's no lag on the processing and network  sides.
But when I use telnet.read_until() I get those feedbacks in the right
order (good) but it's way too slow (it's at least 10 times slower,
toooo bad!!! and, in my case, unusable).

I'm trying to find a way out, and I know in these cases knowledge is
the only way out.
I've seen a huge speed improvement using telnet.read_eager(), I want
to investigate more. Who knows, maybe I can stitch my code around it's
appearant unusability.



More information about the Python-list mailing list