From 9c2438382e49a7b7482c8af5b6b1841e7a90fe9b Mon Sep 17 00:00:00 2001 From: jeancf Date: Wed, 2 Nov 2022 18:38:23 +0100 Subject: [PATCH] Added timeout to get request --- twoot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/twoot.py b/twoot.py index 88f268f..745f47e 100755 --- a/twoot.py +++ b/twoot.py @@ -342,10 +342,13 @@ def main(argv): # Download twitter page of user. try: - twit_account_page = session.get(url, headers=headers) + twit_account_page = session.get(url, headers=headers, timeout=5) except requests.exceptions.ConnectionError: logging.fatal('Host did not respond when trying to download ' + url) exit(-1) + except requests.exceptions.Timeout: + logging.fatal(nitter_url + ' took too long to respond') + exit(-1) # Verify that download worked if twit_account_page.status_code != 200: