Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Adds constants
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle committed Aug 7, 2023
1 parent 37d9d21 commit 25c20bc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion prefect_aws/workers/ecs_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
taskDefinition: "{{ task_definition_arn }}"
"""

# Create task run retry settings
MAX_CREATE_TASK_RUN_ATTEMPTS = 3
CREATE_TASK_RUN_MIN_DELAY_SECONDS = 1
CREATE_TASK_RUN_MIN_DELAY_JITTER_SECONDS = 0
CREATE_TASK_RUN_MAX_DELAY_JITTER_SECONDS = 3

_TASK_DEFINITION_CACHE: Dict[UUID, str] = {}
_TAG_REGEX = r"[^a-zA-Z0-9-_.=+-@: ]+"
Expand Down Expand Up @@ -1422,7 +1427,14 @@ def _prepare_task_run_request(

return task_run_request

@retry(stop=stop_after_attempt(3), wait=wait_fixed(1) + wait_random(0, 3))
@retry(
stop=stop_after_attempt(MAX_CREATE_TASK_RUN_ATTEMPTS),
wait=wait_fixed(CREATE_TASK_RUN_MIN_DELAY_SECONDS)
+ wait_random(
CREATE_TASK_RUN_MIN_DELAY_JITTER_SECONDS,
CREATE_TASK_RUN_MAX_DELAY_JITTER_SECONDS,
),
)
def _create_task_run(self, ecs_client: _ECSClient, task_run_request: dict) -> str:
"""
Create a run of a task definition.
Expand Down

0 comments on commit 25c20bc

Please sign in to comment.