From 7ec6ca605ff52b172acbce02c3956d1d4f018431 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 28 May 2025 13:55:30 +0000 Subject: [PATCH] run_daemon timeout --- src/run_daemon.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/run_daemon.py b/src/run_daemon.py index 25ad7141..29f902ae 100644 --- a/src/run_daemon.py +++ b/src/run_daemon.py @@ -21,8 +21,17 @@ def run(webPath): print(now.strftime("%Y-%m-%d %H:%M:%S"), webPath, flush=True) startTime = getCurrentMillisecTime() - obj = urllib.request.urlopen(webPath) - obj.read() + try: + obj = urllib.request.urlopen(webPath, timeout=60) + obj.read() + except urllib.error.HTTPError as e: + print('HTTPError:', e.code, webPath) + except urllib.error.URLError as e: + print('URLError:', e.reason, webPath) + except Exception as e: + print('Exception:', str(e), webPath) + else: + pass timeGap = getCurrentMillisecTime() - startTime if timeGap < RETRY_SEC * 1000: