mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	fix: swallow Serialization failure
We can swallow the serialization exception because there is a scheduled task that will update these later anyway. Fixes #2241
This commit is contained in:
		@@ -2,6 +2,7 @@ from common.settings import currency_code_default, currency_codes
 | 
				
			|||||||
from urllib.error import HTTPError, URLError
 | 
					from urllib.error import HTTPError, URLError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
 | 
					from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
 | 
				
			||||||
 | 
					from django.db.utils import OperationalError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class InvenTreeExchange(SimpleExchangeBackend):
 | 
					class InvenTreeExchange(SimpleExchangeBackend):
 | 
				
			||||||
@@ -32,3 +33,12 @@ class InvenTreeExchange(SimpleExchangeBackend):
 | 
				
			|||||||
        # catch connection errors
 | 
					        # catch connection errors
 | 
				
			||||||
        except (HTTPError, URLError):
 | 
					        except (HTTPError, URLError):
 | 
				
			||||||
            print('Encountered connection error while updating')
 | 
					            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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user