Added timeout to get request

This commit is contained in:
jeancf 2022-11-02 18:38:23 +01:00
parent b386eae528
commit 9c2438382e

View File

@ -342,10 +342,13 @@ def main(argv):
# Download twitter page of user. # Download twitter page of user.
try: try:
twit_account_page = session.get(url, headers=headers) twit_account_page = session.get(url, headers=headers, timeout=5)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
logging.fatal('Host did not respond when trying to download ' + url) logging.fatal('Host did not respond when trying to download ' + url)
exit(-1) exit(-1)
except requests.exceptions.Timeout:
logging.fatal(nitter_url + ' took too long to respond')
exit(-1)
# Verify that download worked # Verify that download worked
if twit_account_page.status_code != 200: if twit_account_page.status_code != 200: