From 2b5e9c02bb04a098c1b575fc08b35aef5c7c3f0a Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Tue, 21 Jun 2022 08:46:43 +0300 Subject: [PATCH] add timeout to Ping --- server/app/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/app/helpers.py b/server/app/helpers.py index b38dca54..a3c5a520 100644 --- a/server/app/helpers.py +++ b/server/app/helpers.py @@ -183,7 +183,7 @@ class Ping: @staticmethod def __call__() -> bool: try: - requests.get("https://google.com") + requests.get("https://google.com", timeout=10) return True - except requests.exceptions.ConnectionError: + except (requests.exceptions.ConnectionError, requests.Timeout): return False