From db97d76a240919f31e48b8d97c1c51ca06aadbb4 Mon Sep 17 00:00:00 2001 From: Margaret Fero Date: Fri, 1 Mar 2024 19:58:11 -0800 Subject: [PATCH 1/3] Add timeout to isbn.py An instance of requests.get in isbn.py lacks a timeout, and this commit adds one with a default of 15 as used other places in the code, where requests.get does already have a timeout. --- bookwyrm/isbn/isbn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/isbn/isbn.py b/bookwyrm/isbn/isbn.py index 56062ff7b..d14dc2619 100644 --- a/bookwyrm/isbn/isbn.py +++ b/bookwyrm/isbn/isbn.py @@ -26,7 +26,7 @@ class IsbnHyphenator: def update_range_message(self) -> None: """Download the range message xml file and save it locally""" - response = requests.get(self.__range_message_url) + response = requests.get(self.__range_message_url, timeout=15) with open(self.__range_file_path, "w", encoding="utf-8") as file: file.write(response.text) self.__element_tree = None From 1ae9870862626134f90b4f1fb86d06fdd870e6c4 Mon Sep 17 00:00:00 2001 From: Margaret Fero Date: Fri, 1 Mar 2024 20:02:40 -0800 Subject: [PATCH 2/3] Add timeout to base_activity.py An instance of requests.get was missing a timeout; this commit adds a timeout of 15 as used in other places in this codebase which already have timeouts. --- bookwyrm/activitypub/base_activity.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index fbbc18f73..9f1cfdbfb 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -423,6 +423,7 @@ def get_activitypub_data(url): "Date": now, "Signature": make_signature("get", sender, url, now), }, + timeout=15 ) except requests.RequestException: raise ConnectorException() From 50b811d9aa0e117f20851507b385b2020cfcd618 Mon Sep 17 00:00:00 2001 From: Margaret Fero Date: Fri, 1 Mar 2024 20:11:14 -0800 Subject: [PATCH 3/3] Typo fix Add a comma --- bookwyrm/activitypub/base_activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 9f1cfdbfb..890d4d24a 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -423,7 +423,7 @@ def get_activitypub_data(url): "Date": now, "Signature": make_signature("get", sender, url, now), }, - timeout=15 + timeout=15, ) except requests.RequestException: raise ConnectorException()