|
1 | 1 | import asyncio |
2 | 2 | import logging |
3 | 3 | from datetime import timedelta |
4 | | -from typing import Any, Final, TypeVar |
| 4 | +from typing import Annotated, Any, Final, TypeVar |
5 | 5 | from uuid import uuid4 |
6 | 6 |
|
7 | | -from pydantic import ConfigDict, NonNegativeInt, validate_call |
| 7 | +from pydantic import ConfigDict, Field, NonNegativeInt, validate_call |
8 | 8 | from settings_library.rabbit import RabbitSettings |
9 | 9 | from settings_library.redis import RedisSettings |
10 | 10 |
|
@@ -111,7 +111,7 @@ async def _track_job_if_not_tracked( |
111 | 111 | params=params, |
112 | 112 | remaining_attempts=retry_count, |
113 | 113 | ), |
114 | | - timeout=timeout, |
| 114 | + expire=timeout, |
115 | 115 | ) |
116 | 116 |
|
117 | 117 | async def _decrease_remaining_attempts_or_raise( |
@@ -147,7 +147,9 @@ async def _start_job_if_missing( |
147 | 147 | await self._rpc_interface.start( |
148 | 148 | name, unique_id, timeout=timeout, **params |
149 | 149 | ) |
150 | | - await self._store_interface.update_timeout(unique_id, timeout=timeout) |
| 150 | + await self._store_interface.update_entry_expiry( |
| 151 | + unique_id, expire=timeout |
| 152 | + ) |
151 | 153 | except AlreadyStartedError: |
152 | 154 | _logger.info( |
153 | 155 | "unique_id='%s', was already running, did not start", unique_id |
@@ -232,7 +234,7 @@ async def ensure_result( # type: ignore[valid-type] |
232 | 234 | expected_type: type[ResultType], |
233 | 235 | timeout: timedelta, # noqa: ASYNC109 |
234 | 236 | is_unique: bool = False, |
235 | | - retry_count: NonNegativeInt = 3, |
| 237 | + retry_count: Annotated[NonNegativeInt, Field(gt=0)] = 3, |
236 | 238 | **params: Any, |
237 | 239 | ) -> ResultType: |
238 | 240 |
|
|
0 commit comments