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

transient_internet() (test_support): use socket.setdefaulttimeout() and test_robotparser failure #52820

Closed
vstinner opened this issue Apr 29, 2010 · 5 comments

Comments

@vstinner
Copy link
Member

BPO 8574
Nosy @pitrou, @vstinner
Files
  • test_robotparser_transient_internet.patch
  • transient_internet-3.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:32.094>
    created_at = <Date 2010-04-29.23:43:54.030>
    labels = []
    title = 'transient_internet() (test_support): use socket.setdefaulttimeout() and test_robotparser failure'
    updated_at = <Date 2010-09-07.21:40:32.093>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2010-09-07.21:40:32.093>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-07.21:40:32.094>
    closer = 'pitrou'
    components = []
    creation = <Date 2010-04-29.23:43:54.030>
    creator = 'vstinner'
    dependencies = []
    files = ['17135', '17137']
    hgrepos = []
    issue_num = 8574
    keywords = ['patch']
    message_count = 5.0
    messages = ['104596', '104597', '104599', '104600', '115807']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue8574'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @vstinner
    Copy link
    Member Author

    Many tests of the Python test suite depends on the availability of websites, especially www.python.org. Python.org has some troubles since some days, and many buildbots failed (test_robotparser failure).

    I propose to use a default timeout of 60 seconds in transient_internet(), and then use transient_internet() in tests using the internet.

    Patches:

    • transient_internet.py: set temporary the defalt socket timeout to 60 seconds (and then restore the previous default value), and catch also weird IOError (which contain in socket.error as the 2nd argument) from urllib
    • test_robotparser_transient_internet.py: use "with transient_internet():" to do not hung anymore (for 1800 seconds!) if a website is down

    On Linux, you can use "iptables -I OUTPUT -p tcp --dport 80 -j DROP" (drop all outgoing packets) to simulate a network failure, and set the default timeout value of transient_internet() to 3 seconds.

    @vstinner
    Copy link
    Member Author

    Oops, transient_internet.patch doesn't catch socket.error(errno.ETIMEDOUT, ...). Fixed by patch version 2.

    @vstinner
    Copy link
    Member Author

    See also issue bpo-8499.

    @vstinner
    Copy link
    Member Author

    Version 3 to prepare a patch for bpo-8499: don't change socket default timeout if the timeout argument is None.

    @pitrou
    Copy link
    Member

    pitrou commented Sep 7, 2010

    Improved again and committed in r84597 and r84599. Needs backporting.

    @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
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants