diff --git a/sharded_queue/__init__.py b/sharded_queue/__init__.py index 804d85c..1dbe040 100644 --- a/sharded_queue/__init__.py +++ b/sharded_queue/__init__.py @@ -285,7 +285,7 @@ def calculate_timestamp(cls, delta: float | int | timedelta) -> float: timestamp: float = now.timestamp() if not isinstance(delta, timedelta): - timestamp = delta = delta + timestamp = timestamp + delta return timestamp diff --git a/tests/test_recurrent.py b/tests/test_recurrent.py index 3155dc9..b9832c6 100644 --- a/tests/test_recurrent.py +++ b/tests/test_recurrent.py @@ -45,10 +45,15 @@ async def stats() -> tuple[int, int, int]: ) assert await stats() == (0, 1, 0), 'recurrent pipe contains request' + deffered_registration = datetime.now().timestamp() await Worker(lock, queue).loop(1) assert await stats() == (1, 1, 0), 'added defered request' assert await lock.exists(recurrent_pipe) + [deferred] = await queue.storage.range(deferred_pipe, 1) + request = queue.serializer.deserialize(DeferredRequest, deferred) + assert request.timestamp >= deffered_registration + await lock.release(recurrent_pipe) await Worker(lock, queue).loop(1, handler=RecurrentHandler) assert await stats() == (1, 1, 0), 'no deffered duplicates'