Python sockets suddenly timing out?
Question: I came back today to an old script I had for logging into Gmail via SSL. The
script worked fine last time I ran it (several months ago) but now it dies
immediately with:

    
    
    <urlopen error The read operation timed out>
    

If I set the timeout (no matter how long), it dies even more immediately with:

    
    
    <urlopen error The connect operation timed out>
    

The latter is reproducible with:

    
    
    import socket
    socket.setdefaulttimeout(30000)
    sock = socket.socket()
    sock.connect(('www.google.com', 443))
    ssl = socket.ssl(sock)
    

returning:

    
    
    socket.sslerror: The connect operation timed out
    

but I can't seem to reproduce the former and, after much stepping thru the
code, I have no clue what's causing any of this.


Answer: 
    import socket
    socket.setdefaulttimeout(30000)
    sock = socket.socket()
    sock.connect(('www.google.com', 443))
    ssl = socket.ssl(sock)
    ssl.server()
    --> '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com'
    

It works just fine. I can't reproduce your error.

