Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add socket.close(fd) function #76635

tiran opened this issue Dec 30, 2017 · 2 comments

Add socket.close(fd) function #76635

tiran opened this issue Dec 30, 2017 · 2 comments
3.7 type-feature


Copy link

@tiran tiran commented Dec 30, 2017

BPO 32454
Nosy @pfmoore, @tiran, @tjguk, @zware, @zooba
  • #5048
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-01-27.08:57:21.889>
    created_at = <Date 2017-12-30.09:37:23.786>
    labels = ['type-feature', '3.7']
    title = 'Add socket.close(fd) function'
    updated_at = <Date 2018-01-27.08:57:21.888>
    user = '' fields:

    activity = <Date 2018-01-27.08:57:21.888>
    actor = 'christian.heimes'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-27.08:57:21.889>
    closer = 'christian.heimes'
    components = []
    creation = <Date 2017-12-30.09:37:23.786>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32454
    keywords = ['patch']
    message_count = 2.0
    messages = ['309224', '310850']
    nosy_count = 5.0
    nosy_names = ['paul.moore', 'christian.heimes', 'tim.golden', 'zach.ware', 'steve.dower']
    pr_nums = ['5048']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = ''
    versions = ['Python 3.7']

    Copy link
    Member Author

    @tiran tiran commented Dec 30, 2017

    os.close(fd) of a socket fd does not work some platforms, e.g. Windows. In the past we have used socket.socket(fileno=fd).close() to close a socket in a platform independent way. With bpo-28134 it may no longer work in all cases, most noticeable when the socket has neither been connected nor bound yet and auto-detection of type and family is used.

    Instead of adding more hacks, I propose to add a socket.close(fd) function as cross-platform way to close a socket fd. It won't be the first function that mimics an o' module function. The socket module already has the undocumented socket.dup(fd) function.

    @tiran tiran added 3.7 type-feature labels Dec 30, 2017
    Copy link
    Member Author

    @tiran tiran commented Jan 27, 2018

    New changeset d0e31b9 by Christian Heimes in branch 'master':
    bpo-32454: socket closefd (bpo-5048)

    @tiran tiran closed this as completed Jan 27, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    3.7 type-feature
    None yet

    No branches or pull requests

    1 participant