Skip to content

Commit

Permalink
Merge pull request #143 from spacemansteve/master
Browse files Browse the repository at this point in the history
force message retry on update db error
  • Loading branch information
spacemansteve authored Oct 27, 2020
2 parents a6c66d6 + c954ec1 commit 0dd0186
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion adsmp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def update_storage(self, bibcode, type, payload):
except exc.IntegrityError:
self.logger.exception('error in app.update_storage while updating database for bibcode {}, type {}'.format(bibcode, type))
session.rollback()
return None
raise

def delete_by_bibcode(self, bibcode):
with self.session_scope() as session:
Expand Down
3 changes: 1 addition & 2 deletions adsmp/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ def test_update_records(self):
def test_update_records_db_error(self):
"""test database exception IntegrityError is caught"""
with mock.patch('sqlalchemy.orm.session.Session.commit', side_effect=[IntegrityError('a', 'b', 'c', 'd'), None]):
r = self.app.update_storage('abc', 'nonbib_data', '{}')
self.assertIsNone(r)
self.assertRaises(IntegrityError, self.app.update_storage, 'abc', 'nonbib_data', '{}')

def test_rename_bibcode(self):
self.app.update_storage('abc', 'metadata', {'foo': 'bar', 'hey': 1})
Expand Down

0 comments on commit 0dd0186

Please sign in to comment.