Terminating a subprocess question

Fredrik Lundh fredrik at pythonware.com
Wed Mar 29 21:45:26 CEST 2006

Ernesto wrote:

> > > tn = telnetlib.Telnet("localhost",6000)
> > > print tn.read_all()
> > > # CRASH
> >
> > that's an unusual error message.  are you sure you didn't get a
> > traceback?  if so, what did it say?
> I was running it directly in a python shell.  After the tn.read_all()
> call, the python shell window freezes up, and I have to do a hard
> termination of the shell.  There is no traceback message, just a freeze.

hmm.  that hardly qualifies as a "CRASH"; rather, it's pretty much
what you'd expect from a read_all call:

    >>> help(tn.read_all)
    Help on method read_all in module telnetlib:

    read_all(self) method of telnetlib.Telnet instance
        Read all data until EOF; block until connection closed.

(note the "block until connection closed" part)

what happens if you use a non-blocking method instead ?  e.g.

    >>> help(tn.read_very_eager)
    Help on method read_very_eager in module telnetlib:

    read_very_eager(self) method of telnetlib.Telnet instance
        Read everything that's possible without blocking in I/O (eager).

        Raise EOFError if connection closed and no cooked data
        available.  Return '' if no cooked data available otherwise.
        Don't block unless in the midst of an IAC sequence.


More information about the Python-list mailing list