[issue29343] sock.close() raises OSError EBADF when socket's fd is closed
Charles-François Natali
report at bugs.python.org
Mon Jan 23 17:03:48 EST 2017
Charles-François Natali added the comment:
FWIW I agree with Antoine and Martin: ignoring EBADF is a bad idea,
quite dangerous.
The man page probably says this to highlight that users shouldn't
*retry* close():
"""
Retrying the close() after a failure return is the wrong thing to do,
since this may cause a reused file descriptor from another thread to
be closed. This can occur because the Linux kernel always releases
the file descriptor early in the close operation, freeing it for
reuse; the steps that may return an error, such as flushing data to
the filesystem or device, occur only later in the close operation.
"""
(Including on EINTR).
In short, I think that the change is a good idea: Socket.close() is
guaranteed to be idempotent, so this error can only happen in case of
invalid usage.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29343>
_______________________________________
More information about the Python-bugs-list
mailing list