mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
Exchange backend fix (#3253)
* Prevent creation of duplicate backend objects
* Ignore exchange errors, rather than returning None
* Revert "Prevent creation of duplicate backend objects"
This reverts commit 0b6d1ce86f
.
This commit is contained in:
@ -44,8 +44,9 @@ class InvenTreeExchange(SimpleExchangeBackend):
|
|||||||
response = urlopen(url, timeout=5, context=context)
|
response = urlopen(url, timeout=5, context=context)
|
||||||
return response.read()
|
return response.read()
|
||||||
except Exception:
|
except Exception:
|
||||||
# Returning None here will raise an error upstream
|
# Something has gone wrong, but we can just try again next time
|
||||||
return None
|
# Raise a TypeError so the outer function can handle this
|
||||||
|
raise TypeError
|
||||||
|
|
||||||
def update_rates(self, base_currency=None):
|
def update_rates(self, base_currency=None):
|
||||||
"""Set the requested currency codes and get rates."""
|
"""Set the requested currency codes and get rates."""
|
||||||
@ -60,6 +61,8 @@ class InvenTreeExchange(SimpleExchangeBackend):
|
|||||||
# catch connection errors
|
# catch connection errors
|
||||||
except URLError:
|
except URLError:
|
||||||
print('Encountered connection error while updating')
|
print('Encountered connection error while updating')
|
||||||
|
except TypeError:
|
||||||
|
print('Exchange returned invalid response')
|
||||||
except OperationalError as e:
|
except OperationalError as e:
|
||||||
if 'SerializationFailure' in e.__cause__.__class__.__name__:
|
if 'SerializationFailure' in e.__cause__.__class__.__name__:
|
||||||
print('Serialization Failure while updating exchange rates')
|
print('Serialization Failure while updating exchange rates')
|
||||||
|
Reference in New Issue
Block a user