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

socket.create_connection context manager #54003

giampaolo opened this issue Sep 7, 2010 · 5 comments

socket.create_connection context manager #54003

giampaolo opened this issue Sep 7, 2010 · 5 comments
stdlib Python modules in the Lib dir


Copy link

BPO 9794
Nosy @amauryfa, @pitrou, @giampaolo
  • socket_ctx_mgr.patch
  • socket_ctx_mgr.patch
  • socket_ctx_mgr.patch
  • 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 = ''
    closed_at = <Date 2010-09-08.22:44:48.654>
    created_at = <Date 2010-09-07.22:23:47.438>
    labels = ['library']
    title = 'socket.create_connection context manager'
    updated_at = <Date 2010-09-08.22:44:48.653>
    user = '' fields:

    activity = <Date 2010-09-08.22:44:48.653>
    actor = 'giampaolo.rodola'
    assignee = 'giampaolo.rodola'
    closed = True
    closed_date = <Date 2010-09-08.22:44:48.654>
    closer = 'giampaolo.rodola'
    components = ['Library (Lib)']
    creation = <Date 2010-09-07.22:23:47.438>
    creator = 'giampaolo.rodola'
    dependencies = []
    files = ['18789', '18790', '18804']
    hgrepos = []
    issue_num = 9794
    keywords = ['patch']
    message_count = 5.0
    messages = ['115812', '115814', '115817', '115911', '115912']
    nosy_count = 3.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'giampaolo.rodola']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = ''
    versions = ['Python 3.2']

    Copy link
    Contributor Author

    Patch in attachment adds a context manager to socket.socket class so that socket.create_connection() can be used with "with" statement.

    @giampaolo giampaolo added the stdlib Python modules in the Lib dir label Sep 7, 2010
    Copy link

    pitrou commented Sep 7, 2010

    You don't need to use socketserver. Take a look at how the other tests in test_socket are written. Inheriting from ThreadedTCPSocketTest should be easy.

    Copy link
    Contributor Author

    It wasn't easy but here it is. =)
    I'll submit a patch which updates the doc tomorrow.

    @giampaolo giampaolo self-assigned this Sep 7, 2010
    Copy link
    Contributor Author

    Patch which updates doc is in attachment.

    Copy link
    Contributor Author

    Committed in r84639.

    @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
    stdlib Python modules in the Lib dir
    None yet

    No branches or pull requests

    2 participants