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.pyindex 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 Partyfrom openfoodfacts import API+from requests import ConnectTimeout# wgerfrom 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 Noneif not result:logger.info('Product not found')