Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This isn't an issue specific to Python 3 or Windows. Take a look at the docs for create_connection(): <a href="http://docs.python.org/library/socket.html#socket.create_connection" rel="nofollow">http://docs.python.org/library/socket.html#socket.create_connection</a></p> <p>The important snippet is:</p> <blockquote> <p>if host is a non-numeric hostname, it will try to resolve it for both AF_INET and AF_INET6, and then try to connect to all possible addresses in turn until a connection succeeds.</p> </blockquote> <p>It resolves the name using socket.getaddrinfo. If you run</p> <pre><code>socket.getaddrinfo('google.com', 59855, 0, socket.SOCK_STREAM) </code></pre> <p>You'll probably get a few results returned. When you call socket.create_connection, it will iterate over all of those results, each waiting for timeout seconds until it fails. Because it waits timeout seconds for EACH result, the total time is obviously going to be greater than timeout. </p> <p>If you call create_connection with an IP address rather than host name, e.g.</p> <pre><code>testconn = socket.create_connection(('74.125.226.201', 59855), timeout=5) </code></pre> <p>you should get your 5 second timeout.</p> <p>And if you're really curious, take a look at the source for create_connection. It's pretty simple and you can see the loop that is causing your problems: <a href="http://hg.python.org/releasing/3.2.3/file/86d1421a552c/Lib/socket.py" rel="nofollow">http://hg.python.org/releasing/3.2.3/file/86d1421a552c/Lib/socket.py</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload