[Python-Dev] Comments of the PEP 3151

Antoine Pitrou solipsis at pitrou.net
Wed Jul 27 01:45:18 CEST 2011


On Tue, 26 Jul 2011 19:32:56 -0400
Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:
> 
> On Jul 26, 2011, at 6:49 PM, Antoine Pitrou wrote:
> 
> > On Mon, 25 Jul 2011 15:28:47 +1000
> > Nick Coghlan <ncoghlan at gmail.com> wrote:
> >> There may be some error codes that we choose to map to these generic
> >> errors, even if we don't give them their own exception types at this
> >> point (e.g. ECONSHUTDOWN could map directly to ConnectionError).
> > 
> > Ok, I can find neither ECONSHUTDOWN nor ECONNSHUTDOWN on
> > www.opengroup.org, and it's not mentioned in errnomodule.c.  Is it some
> > system-specific error code?
> 
> I assume that ESHUTDOWN is the errno in question?  (This is also already mentioned in the PEP.)

Indeed, I mentioned it in the PEP, as it appears in asyncore.py.
But I can't find it on www.opengroup.org, and no man page on my Linux
system (except the "errno" man page) seems to mention it.

The description from errnomodule.c says "Cannot send after transport
endpoint shutdown", but send() actually returns EPIPE, not ESHUTDOWN,
when the socket has been shutdown:

>>> conn = socket.create_connection(("www.python.org", 80))
>>> conn.shutdown(socket.SHUT_WR)
>>> conn.send(b"xxx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.error: [Errno 32] Broken pipe

From the send() man page:

       EPIPE  The  local  end has been shut down on a connection
       oriented socket.  In this case the process will also receive a
       SIGPIPE unless MSG_NOSIGNAL is set.

Regards

Antoine.


More information about the Python-Dev mailing list