Created
March 30, 2020 15:31
-
-
Save abhirama/09b2b7ad09cbe14ad5b58202da0268af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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