44from framework .exceptions import HTTPError
55from framework .celery_tasks import app as celery_app
66from framework .postcommit_tasks .handlers import enqueue_postcommit_task , get_task_from_postcommit_queue
7+ from website .identifiers .clients .exceptions import CrossRefUnavailableError
8+ from website .settings import CROSSREF_UNAVAILABLE_DELAY
79
810
911CROSSREF_FAIL_RETRY_DELAY = 12 * 60 * 60
@@ -68,6 +70,7 @@ def update_or_enqueue_on_preprint_updated(preprint_id, saved_fields=None):
6870@celery_app .task (bind = True , acks_late = True , max_retries = 5 , default_retry_delay = CROSSREF_FAIL_RETRY_DELAY )
6971def mint_doi_on_crossref_fail (self , preprint_id ):
7072 from osf .models import Preprint
73+
7174 preprint = Preprint .load (preprint_id )
7275 vg = preprint .versioned_guids .first ()
7376 existing_versions_without_minted_doi = Preprint .objects .filter (
@@ -84,5 +87,9 @@ def mint_doi_on_crossref_fail(self, preprint_id):
8487 self .retry ()
8588 else :
8689 crossref_client = preprint .get_doi_client ()
87- if crossref_client :
88- crossref_client .create_identifier (preprint , category = 'doi' , include_relation = False )
90+ try :
91+ if crossref_client :
92+ crossref_client .create_identifier (preprint , category = 'doi' , include_relation = False )
93+ except CrossRefUnavailableError as err :
94+ logger .warning (f'CrossRef is unavailable during minting DOI on fail for preprint { preprint_id } . Error: { err .error } ' )
95+ self .retry (countdown = CROSSREF_UNAVAILABLE_DELAY )
0 commit comments