mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-31 16:38:14 +00:00
Ignore IntegrityError when we're attempting to save a API doc
This commit is contained in:
@@ -4,7 +4,7 @@ import urllib, urllib2
|
|||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from django.db import models
|
from django.db import models, IntegrityError
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from eve_proxy.exceptions import *
|
from eve_proxy.exceptions import *
|
||||||
|
|
||||||
@@ -105,7 +105,11 @@ class CachedDocumentManager(models.Manager):
|
|||||||
|
|
||||||
# If we have a error in the ignored error list use the cached doc, otherwise return the new doc
|
# If we have a error in the ignored error list use the cached doc, otherwise return the new doc
|
||||||
if not error or not error in ROLLBACK_ERRORS:
|
if not error or not error in ROLLBACK_ERRORS:
|
||||||
doc.save()
|
try:
|
||||||
|
doc.save()
|
||||||
|
except IntegrityError:
|
||||||
|
# Ignore IntegrityError for this instance, just reload the doc from store
|
||||||
|
pass
|
||||||
doc = self.get(pk=doc.pk)
|
doc = self.get(pk=doc.pk)
|
||||||
elif error in ROLLBACK_ERRORS and not created:
|
elif error in ROLLBACK_ERRORS and not created:
|
||||||
logger.info("API Error %s encountered" % error, extra={'data': {'api-url': url, 'error': error, 'document': doc.body}})
|
logger.info("API Error %s encountered" % error, extra={'data': {'api-url': url, 'error': error, 'document': doc.body}})
|
||||||
|
|||||||
Reference in New Issue
Block a user