Debugging "broken pipe" (in telnetlib)

Jean-Paul Calderone exarkun at divmod.com
Tue Jul 3 15:03:29 CEST 2007


On Tue, 03 Jul 2007 05:12:22 -0700, Samuel <knipknap at gmail.com> wrote:
>Hi,
>
>When using telnetlib, the connection sometimes breaks with the
>following error:
>
>"error: (32, 'Broken pipe')"
>
>where the traceback points to
>
>self.sock.send(buffer)
>
>in telnetlib.py. The problem is unreproducible, but happens fairly
>often (approx. 5% of the time). Any idea how to debug such a problem?
>How can I find out what broke the pipe?

EPIPE results when writing to a socket for which writing has been shutdown.
This most commonly occurs when the socket has closed.  You need to handle
this exception, since you can't absolutely prevent the socket from being
closed.  There might be some other change which would be appropriate, though,
if it is the case that something your application is doing is causing the
socket to be closed (for example, sending a message which the remote side
decides is invalid and causing it to close the socket explicitly from its
end).  It's difficult to make any specific suggestions in that area without
knowing exactly what your program does.

Jean-Paul



More information about the Python-list mailing list