Skip to content

Commit

Permalink
fix: handle metadata attempt/dispatch == 0
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed May 23, 2023
1 parent 0644cc4 commit 495565f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_cloud_tasks/tasks/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def from_headers(cls, headers: dict) -> Self:
# Available data: https://cloud.google.com/tasks/docs/creating-http-target-tasks#handler
cloud_tasks_prefix = "X-Cloudtasks-"

if attempt_str := headers.get(f"{cloud_tasks_prefix}Taskexecutioncount"):
if (attempt_str := headers.get(f"{cloud_tasks_prefix}Taskexecutioncount")) is not None:
execution_number = int(attempt_str)
else:
execution_number = None

if retry_str := headers.get(f"{cloud_tasks_prefix}Taskretrycount"):
if retry_str := headers.get(f"{cloud_tasks_prefix}Taskretrycount") is not None:
dispatch_number = int(retry_str)
else:
dispatch_number = None
Expand Down

0 comments on commit 495565f

Please sign in to comment.