[issue28447] socket.getpeername() failure on broken TCP/IP connection

Martin Panter report at bugs.python.org
Fri Oct 14 21:31:39 EDT 2016


Martin Panter added the comment:

The getpeername() method is just a wrapper around the OS function, so it is not going to work if the socket file descriptor is closed or invalid (-1).

You haven’t provided enough code or information for someone else to reproduce the problem. But it sounds like you may be closing the socket in one thread, and trying to use it in another thread. This is going to be unreliable and racy, depending on which thread acts on the socket first. Perhaps you should save the peer address in the same thread that closes it, so you can guarantee when it is open and when it is closed. Or use something else to synchronize the two threads and ensure the socket is always closed after getpeername() is called.

BTW it looks like I have to remove George’s username from the nosy list because it contains a comma!

----------
nosy: +martin.panter -George,Y
resolution:  -> not a bug

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


More information about the Python-bugs-list mailing list