Josh Rosenberg added the comment: You used the `fileno` based initialization in the child, which creates a wrapper around the same file descriptor without duplicating it, so when the first socket disappears, that file descriptor becomes invalid.
I think this is a doc bug more than a behavior bug; the docs say "Unlike socket.fromfd(), fileno will return the same socket and not a duplicate." which almost seems like the idea is that the Python level socket object it returns is cached in some way that allows it to be looked up by file descriptor (making mysock2 = socket.socket(fileno=mysock.fileno()) equivalent to mysock2 = mysock), but what it really means is that there are two Python level socket objects referencing the same C level file descriptor; the normal cleanup behavior still applies though, so the first Python level socket object to be destroyed also closes the file descriptor, leaving the other socket object in a broken state. The correct approach to this would be to just pass the socket object to the thread directly, or pass along the address family and type and use socket.fromfd (which dups the underlying file descriptor). ---------- nosy: +josh.r _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26703> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com