Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import requests
from timeit import default_timer as timer
from requests import exceptions as e
start = timer()
try:
requests.get("https://api.github.com:88", timeout=(3.4, 20))
except e.ConnectTimeout:
end = timer()
print("Time spent waiting for socket connection -", end - start, "Seconds")
start = timer()
try:
requests.get("https://api.github.com:88", timeout=(6.4, 20))
except e.ConnectTimeout:
end = timer()
print("Time spent waiting for socket connection -", end - start, "Seconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment