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

create_connection() recasts timeout errors #54001

Closed
pitrou opened this issue Sep 7, 2010 · 4 comments
Closed

create_connection() recasts timeout errors #54001

pitrou opened this issue Sep 7, 2010 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Sep 7, 2010

BPO 9792
Nosy @facundobatista, @pitrou, @giampaolo
Files
  • createconn.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 = None
    closed_at = <Date 2010-09-07.21:40:36.360>
    created_at = <Date 2010-09-07.19:50:11.662>
    labels = ['type-bug', 'library']
    title = 'create_connection() recasts timeout errors'
    updated_at = <Date 2010-09-07.21:40:36.360>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-09-07.21:40:36.360>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-07.21:40:36.360>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2010-09-07.19:50:11.662>
    creator = 'pitrou'
    dependencies = []
    files = ['18788']
    hgrepos = []
    issue_num = 9792
    keywords = ['patch']
    message_count = 4.0
    messages = ['115798', '115802', '115804', '115806']
    nosy_count = 4.0
    nosy_names = ['facundobatista', 'exarkun', 'pitrou', 'giampaolo.rodola']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9792'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 7, 2010

    When you call socket.create_connection() and it fails because it hits the socket timeout, the socket.timeout error is recast as a generic socket.error, which makes analyzing the failure more difficult (also, it means the "errno" attribute is lost for other types of errors):

    >>> socket.setdefaulttimeout(0.000001)
    >>> s = socket.socket()
    >>> s.connect(("www.yahoo.fr", 80))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    socket.timeout: timed out
    >>> socket.create_connection(("www.yahoo.fr", 80))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/antoine/py3k/__svn__/Lib/socket.py", line 319, in create_connection
        raise err
    socket.error: timed out

    @pitrou pitrou added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 7, 2010
    @giampaolo
    Copy link
    Contributor

    On Ubuntu 10.04:

    giampaolo@ubuntu:~/svn/python-3.2$ ./python 
    Python 3.2a1+ (py3k:84457, Sep  3 2010, 20:18:38) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> import socket
    >>> socket.setdefaulttimeout(0.000001)
    >>> s = socket.socket()
    >>> s.connect(("www.yahoo.fr", 80))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    socket.timeout: timed out
    >>>

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 7, 2010

    Here is a patch.

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 7, 2010

    Patch committed in r84598. Needs backporting to 3.1 and 2.7.

    @pitrou pitrou closed this as completed Sep 7, 2010
    @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
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants