From 92ac7b7a351b493c6ff6ed17a6fa3bba486d8378 Mon Sep 17 00:00:00 2001 From: Watchful1 Date: Mon, 28 Aug 2023 19:36:25 -0700 Subject: [PATCH] Catch connection errors here --- personal/combine/build_day.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/personal/combine/build_day.py b/personal/combine/build_day.py index 2c84012..2e3c125 100644 --- a/personal/combine/build_day.py +++ b/personal/combine/build_day.py @@ -31,9 +31,13 @@ def query_pushshift(ids, bearer, object_type): log.debug(f"pushshift query: {url}") response = None for i in range(4): - response = requests.get(url, headers={ - 'User-Agent': "In script by /u/Watchful1", - 'Authorization': f"Bearer {bearer}"}, timeout=15) + try: + response = requests.get(url, headers={ + 'User-Agent': "In script by /u/Watchful1", + 'Authorization': f"Bearer {bearer}"}, timeout=15) + except ConnectionError: + time.sleep(2) + continue if response.status_code == 200: break if response.status_code == 403: