From 13edcd4e13e76c4551a10d6ffba1235efafbd976 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:37:56 +1300 Subject: [PATCH] retry get requests --- app/activitypub/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index a6561e66..31aee555 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -217,7 +217,11 @@ def find_actor_or_create(actor: str) -> Union[User, Community, None]: return user else: # User does not exist in the DB, it's going to need to be created from it's remote home instance if actor.startswith('https://'): - actor_data = get_request(actor, headers={'Accept': 'application/activity+json'}) + try: + actor_data = get_request(actor, headers={'Accept': 'application/activity+json'}) + except requests.exceptions.ReadTimeout: + time.sleep(randint(3, 10)) + actor_data = get_request(actor, headers={'Accept': 'application/activity+json'}) if actor_data.status_code == 200: actor_json = actor_data.json() actor_data.close()