connectTimeout parameter

Can someone please explain why this code will return "IOError:" immediately instead of waiting 10 seconds and then raising an exception?

import time
import traceback

start_time = time.time()
#	print"")  # works
	print'', connectTimeout=10000)
	print traceback.format_exc()
print time.time() - start_time

Because connect timeout is specifically about the maximum time to wait when opening a TCP socket.

Presumably here you're getting some kind of immediate response, either from DNS or the TCP connection being denied, not ignored.

Okay, thank you Kevin. I misunderstood connectTimeout. Is there any way to "gracefully" handle this outside of adding logic with retrying the connection in an try/except/sleep loop?

Gracefully handle what? What's the actual problem you're trying to solve?

Also since this is 8.1 you should be using instead.

Doing a GET/POST to some endpoint, but retrying x amount of times if connection fails. Say it's my localhost:8088 Ignition Gateway. If the service is off, it returns an IOError immediately. I initially thought connectTimeout would wait 10 seconds regardless.

What does waiting 10 seconds buy you? Just not having to manage the delay between retries?

You'll have to do it all yourself.

Precisely, thank you for clearing this up.