Skip to content

Commit

Permalink
Use attempts everywhere instead of retries
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Oct 14, 2024
1 parent ec842cf commit 1033c17
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions adit/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def broadcast_mail(subject: str, message: str):
# TODO: Increase the priority slightly when it will be retried
# See https://github.com/procrastinate-org/procrastinate/issues/1096
retry=RetryStrategy(
max_attempts=settings.DICOM_TASK_RETRIES,
max_attempts=settings.DICOM_TASK_MAX_ATTEMPTS,
exponential_wait=settings.DICOM_TASK_EXPONENTIAL_WAIT,
retry_exceptions={RetriableDicomError},
),
Expand Down Expand Up @@ -136,7 +136,7 @@ def _monitor_task(context: JobContext, future: ProcessFuture) -> None:
# Cave, the the attempts of the Procrastinate job must not be the same number
# as the attempts of the DicomTask. The DicomTask could be started by multiple
# Procrastinate jobs (e.g. if the user canceled and resumed the same task).
if context.job.attempts < settings.DICOM_TASK_RETRIES:
if context.job.attempts < settings.DICOM_TASK_MAX_ATTEMPTS:
dicom_task.status = DicomTask.Status.PENDING
dicom_task.message = "Task failed, but will be retried."
if dicom_task.log:
Expand Down
4 changes: 2 additions & 2 deletions adit/core/templates/core/_dicom_task_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<dd class="col-sm-9">
<span class="{{ task.status|dicom_task_status_css_class }}">{{ task.get_status_display }}</span>
</dd>
<dt class="col-sm-3">Retries</dt>
<dt class="col-sm-3">Attempts</dt>
<dd class="col-sm-9">
{{ task.retries|default:"—" }}
{{ task.attempts|default:"—" }}
</dd>
<dt class="col-sm-3">Message</dt>
<dd class="col-sm-9">
Expand Down
4 changes: 2 additions & 2 deletions adit/core/templates/core/_transfer_task_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<dd class="col-sm-9">
<span class="{{ task.status|dicom_task_status_css_class }}">{{ task.get_status_display }}</span>
</dd>
<dt class="col-sm-3">Retries</dt>
<dt class="col-sm-3">Attempts</dt>
<dd class="col-sm-9">
{{ task.retries|default:"—" }}
{{ task.attempts|default:"—" }}
</dd>
<dt class="col-sm-3">Message</dt>
<dd class="col-sm-9">
Expand Down
2 changes: 1 addition & 1 deletion adit/core/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_model_label(model: type[models.Model]) -> str:
def reset_tasks(tasks: models.QuerySet["DicomTask"]) -> None:
tasks.update(
status=tasks.model.Status.PENDING,
retries=0,
attempts=0,
message="",
log="",
start=None,
Expand Down
2 changes: 1 addition & 1 deletion adit/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
ENABLE_DICOM_DEBUG_LOGGER = False

# How often to retry a failed dicom task before it is definitively failed
DICOM_TASK_RETRIES = 3
DICOM_TASK_MAX_ATTEMPTS = 3

# How long to wait in seconds before retrying a failed dicom task (exponential backoff)
DICOM_TASK_EXPONENTIAL_WAIT = 10 # 10 seconds
Expand Down

0 comments on commit 1033c17

Please sign in to comment.