Skip to content

Instantly share code, notes, and snippets.

@abhirama
Created March 30, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirama/09b2b7ad09cbe14ad5b58202da0268af to your computer and use it in GitHub Desktop.
Save abhirama/09b2b7ad09cbe14ad5b58202da0268af to your computer and use it in GitHub Desktop.
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