]> git.0d.be Git - django-panik-nonstop.git/commitdiff
airtime tracker: handle API request errors
authorFrédéric Péters <fpeters@0d.be>
Thu, 2 Feb 2023 12:11:33 +0000 (13:11 +0100)
committerFrédéric Péters <fpeters@0d.be>
Thu, 2 Feb 2023 12:11:33 +0000 (13:11 +0100)
nonstop/management/commands/airtime_tracker.py

index 9cd28f2d9764aad6bdbd88ef7412ad7f639cc9a4..fc1042191f685e5ee1668631cf231fc7e458316d 100644 (file)
@@ -29,7 +29,12 @@ class Command(BaseCommand):
         # run until killed, and starts back where it was killed
         while True:
             logger.debug('Checking API')
-            resp = requests.get(live_info_url)
+            try:
+                resp = requests.get(live_info_url, timeout=10)
+            except requests.RequestException as err:
+                logger.error('Got error requesting API (%s)', err)
+                time.sleep(60)
+                continue
             if not resp.ok:
                 logger.error('Got invalid API answer (%s)', resp.status_code)
                 time.sleep(60)