Skip to content

Commit f9b1f79

Browse files
committed
Updated dependencies, fixed errors.
Signed-off-by: Pavel Kirilin <win10@list.ru>
1 parent 3bd1412 commit f9b1f79

File tree

8 files changed

+312
-450
lines changed

8 files changed

+312
-450
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ RedisAsyncResultBackend parameters:
7979
* `keep_results` - flag to not remove results from Redis after reading.
8080
* `result_ex_time` - expire time in seconds (by default - not specified)
8181
* `result_px_time` - expire time in milliseconds (by default - not specified)
82-
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
83-
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
82+
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
83+
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
8484
>```python
8585
># First variant
8686
>redis_async_result = RedisAsyncResultBackend(
@@ -93,4 +93,4 @@ RedisAsyncResultBackend parameters:
9393
> redis_url="redis://localhost:6379",
9494
> result_px_time=1000000,
9595
>)
96-
>```
96+
>```

poetry.lock

Lines changed: 287 additions & 435 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ repository = "https://github.com/taskiq-python/taskiq-redis"
1818
keywords = ["taskiq", "tasks", "distributed", "async", "redis", "result_backend"]
1919

2020
[tool.poetry.dependencies]
21-
python = "^3.7"
21+
python = "^3.8.1"
2222
taskiq = "^0"
2323
redis = "^4.2.0"
2424

2525
[tool.poetry.dev-dependencies]
2626
pytest = "^7.0"
27-
flake8 = "^4.0.1"
27+
flake8 = "^6"
2828
mypy = "^0.961"
2929
isort = "^5.10.1"
3030
yesqa = "^1.3.0"
31-
wemake-python-styleguide = "^0.16.1"
31+
wemake-python-styleguide = "^0.18"
3232
black = "^22.3.0"
3333
autoflake = "^1.4"
3434
pytest-cov = "^3.0.0"

taskiq_redis/exceptions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
class TaskIQRedisError(Exception):
1+
from taskiq.exceptions import ResultBackendError, ResultGetError, TaskiqError
2+
3+
4+
class TaskIQRedisError(TaskiqError):
25
"""Base error for all taskiq-redis exceptions."""
36

47

5-
class DuplicateExpireTimeSelectedError(TaskIQRedisError):
8+
class DuplicateExpireTimeSelectedError(ResultBackendError, TaskIQRedisError):
69
"""Error if two lifetimes are selected."""
710

811

9-
class ExpireTimeMustBeMoreThanZeroError(TaskIQRedisError):
12+
class ExpireTimeMustBeMoreThanZeroError(ResultBackendError, TaskIQRedisError):
1013
"""Error if two lifetimes are less or equal zero."""
1114

1215

13-
class ResultIsMissingError(TaskIQRedisError):
16+
class ResultIsMissingError(TaskIQRedisError, ResultGetError):
1417
"""Error if there is no result when trying to get it."""

taskiq_redis/redis_backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from redis.asyncio import ConnectionPool, Redis
55
from taskiq import AsyncResultBackend
66
from taskiq.abc.result_backend import TaskiqResult
7+
from taskiq.exceptions import ResultGetError
78

89
from taskiq_redis.exceptions import (
910
DuplicateExpireTimeSelectedError,
@@ -100,7 +101,7 @@ async def is_result_ready(self, task_id: str) -> bool:
100101
async with Redis(connection_pool=self.redis_pool) as redis:
101102
return bool(await redis.exists(task_id))
102103

103-
async def get_result( # noqa: WPS210
104+
async def get_result(
104105
self,
105106
task_id: str,
106107
with_logs: bool = False,
@@ -112,6 +113,8 @@ async def get_result( # noqa: WPS210
112113
:param with_logs: if True it will download task's logs.
113114
:raises ResultIsMissingError: if there is no result when trying to get it.
114115
:return: task's return value.
116+
117+
:raises ResultGetError: if result doesn't exist.
115118
"""
116119
async with Redis(connection_pool=self.redis_pool) as redis:
117120
if self.keep_results:

tests/test_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TypeVar
44

55
import pytest
6-
from taskiq import TaskiqResult
6+
from taskiq import ResultGetError, TaskiqResult
77

88
from taskiq_redis import RedisAsyncResultBackend
99
from taskiq_redis.exceptions import (

tests/test_broker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import asyncio
22
import uuid
3+
from typing import Union
34

45
import pytest
5-
from taskiq import AsyncBroker, BrokerMessage
6+
from taskiq import AckableMessage, AsyncBroker, BrokerMessage
67

78
from taskiq_redis import ListQueueBroker, PubSubBroker
89

910

10-
async def get_message(broker: AsyncBroker) -> bytes: # type: ignore
11+
async def get_message( # type: ignore
12+
broker: AsyncBroker,
13+
) -> Union[bytes, AckableMessage]:
1114
"""
1215
Get a message from the broker.
1316

tests/test_result_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from taskiq import TaskiqResult
55

66
from taskiq_redis import RedisAsyncResultBackend
7+
from taskiq_redis.exceptions import ResultIsMissingError
78

89

910
@pytest.mark.anyio
@@ -94,7 +95,7 @@ async def test_remove_results_after_reading(redis_url: str) -> None:
9495
)
9596

9697
await result_backend.get_result(task_id=task_id)
97-
with pytest.raises(Exception):
98+
with pytest.raises(ResultIsMissingError):
9899
await result_backend.get_result(task_id=task_id)
99100

100101

0 commit comments

Comments
 (0)