From 85964f283ecb75a1c85b4e7d882b0006c7cd821d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Wed, 31 May 2023 14:19:43 +0200 Subject: [PATCH] Add timeout to any outbound connection (#1756) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add timeout to any outbound connection * Change log message to error --------- Co-authored-by: Adrià Casajús --- app/subscription_webhook.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/subscription_webhook.py b/app/subscription_webhook.py index 57952520..70a447ed 100644 --- a/app/subscription_webhook.py +++ b/app/subscription_webhook.py @@ -22,7 +22,7 @@ def execute_subscription_webhook(user: User): "active_subscription_end": sl_subscription_end, } try: - response = requests.post(webhook_url, json=payload) + response = requests.post(webhook_url, json=payload, timeout=2) if response.status_code == 200: LOG.i("Sent request to subscription update webhook successfully") else: @@ -30,4 +30,4 @@ def execute_subscription_webhook(user: User): f"Request to webhook failed with statue {response.status_code}: {response.text}" ) except RequestException as e: - LOG.warn(f"Subscription request exception: {e}") + LOG.error(f"Subscription request exception: {e}")