Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Handle connection timeout when retrieving products from OFF

Roland Geidera6fb99f9b5f5
diff --git a/wger/nutrition/models/ingredient.py b/wger/nutrition/models/ingredient.py
index 00ef106b0..44ffee85f 100644
--- a/wger/nutrition/models/ingredient.py
+++ b/wger/nutrition/models/ingredient.py
@@ -38,6 +38,7 @@ from django.utils.translation import gettext_lazy as _
# Third Party
from openfoodfacts import API
+from requests import ConnectTimeout
# wger
from wger.core.models import Language
@@ -424,6 +425,9 @@ class Ingredient(AbstractLicenseModel, models.Model):
except JSONDecodeError as e:
logger.info(f'Got JSONDecodeError from OFF: {e}')
return None
+ except ConnectTimeout:
+ logger.info('Timeout from OFF')
+ return None
if not result:
logger.info('Product not found')