.
This commit is contained in:
+14
-2
@@ -6,7 +6,7 @@ from celery import shared_task
|
||||
from atlas.models import Case
|
||||
from generic.models import CimarCase
|
||||
from rad.settings import REMOTE_URL, CIMAR_USERNAME, CIMAR_PASSWORD
|
||||
from helpers.cimar import CimarAPI
|
||||
from helpers.cimar import CimarAPI, NotFoundError
|
||||
from pydicom.uid import generate_uid
|
||||
|
||||
@shared_task()
|
||||
@@ -25,7 +25,19 @@ def push_case_to_cimar_task(case_id):
|
||||
data = api.upload_dicom(image.image.path, study_uid=study_uid)
|
||||
|
||||
|
||||
cimar_uuid = api.get_study_by_study_uid(data["study_uid"])["uuid"]
|
||||
retries = 3
|
||||
delay = 1
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
cimar_uuid = api.get_study_by_study_uid(data["study_uid"])["uuid"]
|
||||
break
|
||||
except NotFoundError:
|
||||
if attempt < retries - 1:
|
||||
sleep(delay)
|
||||
delay *= 2
|
||||
else:
|
||||
cimar_uuid = api.get_study_by_study_uid(data["study_uid"])["uuid"]
|
||||
|
||||
|
||||
case.cimar_uuid = cimar_uuid
|
||||
|
||||
|
||||
Reference in New Issue
Block a user