This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients YoSTEALTH, christian.heimes, martin.panter, pitrou, r.david.murray, vstinner, yselivanov
Date 2018-02-24.09:50:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
File descriptors are a advanced features and expose low level operating system resources. You really have to understand how the OS works. They cannot be reference counted. In fact they *are* the reference to entries in the Kernel's global open file table. I gave a talked about FDs at PyCon US two years ago, maybe will help you understand fds better.

You can make your example work with

def accept(sock):
    client, addr = sock.accept()
    inside = socket(fileno=client.fileno())
    return inside
    # after return, the client socket is closed by due to detach the fd isn't no longer close

The feature works as intended. It's designed to turn an inherited file descriptor (e.g. systemd socket activation) or transfered fds (e.g. through AF_UNIX SCM_RIGHTS). In both cases the fd is already a duplicated fd.
Date User Action Args
2018-02-24 09:50:34christian.heimessetrecipients: + christian.heimes, pitrou, vstinner, r.david.murray, martin.panter, yselivanov, YoSTEALTH
2018-02-24 09:50:34christian.heimessetmessageid: <>
2018-02-24 09:50:34christian.heimeslinkissue28134 messages
2018-02-24 09:50:34christian.heimescreate