Merge pull request #2427 from nwns/fix/overlapping_currency

Swallow Serialization failure while updating exchange rates
This commit is contained in:
Oliver 2021-12-06 09:49:54 +11:00 committed by GitHub
commit b7f3a044d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ from common.settings import currency_code_default, currency_codes
from urllib.error import HTTPError, URLError
from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
from django.db.utils import OperationalError
class InvenTreeExchange(SimpleExchangeBackend):
@ -32,3 +33,12 @@ class InvenTreeExchange(SimpleExchangeBackend):
# catch connection errors
except (HTTPError, URLError):
print('Encountered connection error while updating')
except OperationalError as e:
if 'SerializationFailure' in e.__cause__.__class__.__name__:
print('Serialization Failure while updating exchange rates')
# We are just going to swallow this exception because the
# exchange rates will be updated later by the scheduled task
else:
# Other operational errors probably are still show stoppers
# so reraise them so that the log contains the stacktrace
raise