Skip to content

Commit

Permalink
Add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Arti3DPlayer committed Dec 19, 2023
1 parent 14cad93 commit 164203a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cloudtask/tasks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import Any, Callable, Union
from functools import cached_property, partial
from google.protobuf import timestamp_pb2 # type: ignore
from google.protobuf import timestamp_pb2, duration_pb2 # type: ignore

from django.http.request import HttpRequest
from django.utils.module_loading import import_string
Expand Down Expand Up @@ -130,7 +130,9 @@ def get_http_body(self) -> dict:
}

if self.timeout:
body['dispatch_deadline'] = f"{self.timeout}s"
duration = duration_pb2.Duration()
duration.FromSeconds(self.timeout)
body['dispatch_deadline'] = duration
if self.named:
body['name'] = self.task_path
return body
Expand Down

0 comments on commit 164203a

Please sign in to comment.