From 5ca786b1ae169f986ebd13f08d2776da93882183 Mon Sep 17 00:00:00 2001 From: bitscuit Date: Sat, 8 May 2021 18:15:32 +0200 Subject: [PATCH] Added exception handling during get --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 013f235..6280fc5 100644 --- a/main.py +++ b/main.py @@ -21,8 +21,14 @@ while not urls.empty(): # Perform request print("Fetching url '%s'..."%url, end="") - r = session.get(url) - print("\tdone") + try: + r = session.get(url) + print("\tdone") + except Exception as e: + print("\tfailed") + print(e) + finally: + r.close() # Read response if r.status_code != 200: