From 164203a88cc886f3b706805d1daf503a1f29221d Mon Sep 17 00:00:00 2001 From: Artem Hruzd Date: Tue, 19 Dec 2023 21:39:09 +0200 Subject: [PATCH] Add timeout --- cloudtask/tasks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudtask/tasks.py b/cloudtask/tasks.py index 5f52655..74db274 100644 --- a/cloudtask/tasks.py +++ b/cloudtask/tasks.py @@ -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 @@ -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