[issue30319] Change socket.close() to ignore ECONNRESET

Antoine Pitrou report at bugs.python.org
Tue Jul 4 08:06:52 EDT 2017


Antoine Pitrou added the comment:

Le 04/07/2017 à 14:00, STINNER Victor a écrit :
> 
> Antoine Pitrou: "shutdown() is not the same thing as close()."
> 
> I consider that the bug is similar to socket.close() error,
> [...]

First, let's not call it a bug when an error is reported to the user.  A
bug would be to silence all errors just because they annoy one core
developer.

Second, close() and shutdown() are different functions operating at
different levels.  close() operates at the OS level and releases
resources associated with the given file descriptor.  It might, but
might not, do any I/O (such as flush buffers or send a TCP RST) -- for
example, if you duplicated a fd after fork(), calling close() on only
one of them will do absolutely nothing at the I/O level.

shutdown() operates at the transport level.  Someone who calls
shutdown() *must* be notified that the shutdown went wrong, because
that's the only thing shutdown() does.  shutdown() does nothing at the
OS level.

It makes sense to silence some errors in close() because, most of the
time, people call close() to release resources and they don't care
whether the other end of the connection was notified in time.  It
doesn't make sense to do the same for shutdown().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30319>
_______________________________________


More information about the Python-bugs-list mailing list