From b081f2af2c3f808a4b7f0672351c12428c83ce9e Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 22 May 2019 16:20:09 -0700 Subject: pubmed: try to work around multi-edits --- python/fatcat_tools/importers/pubmed.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/fatcat_tools/importers/pubmed.py b/python/fatcat_tools/importers/pubmed.py index e5d413a7..923c5492 100644 --- a/python/fatcat_tools/importers/pubmed.py +++ b/python/fatcat_tools/importers/pubmed.py @@ -739,9 +739,19 @@ class PubmedImporter(EntityImporter): existing.ext_ids.pmcid = existing.ext_ids.pmcid or re.ext_ids.pmcid existing.refs = existing.refs or re.refs existing.extra['pubmed'] = re.extra['pubmed'] - self.api.update_release(self.get_editgroup_id(), existing.ident, existing) - self.counts['update'] += 1 - return False + try: + self.api.update_release(self.get_editgroup_id(), existing.ident, existing) + self.counts['update'] += 1 + except fatcat_client.rest.ApiException as err: + # there is a code path where we try to update the same release + # twice in a row; if that happens, just skip + # NOTE: API behavior might change in the future? + if "release_edit_editgroup_id_ident_id_key" in err.body: + self.counts['skip-update-conflict'] += 1 + else: + raise err + finally: + return False return True -- cgit v1.2.3