Skip to content

Commit 916c552

Browse files
committed
Updated dependencies, fixed errors.
Signed-off-by: Pavel Kirilin <[email protected]>
1 parent 01a5b96 commit 916c552

File tree

7 files changed

+310
-448
lines changed

7 files changed

+310
-448
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ RedisAsyncResultBackend parameters:
7272
* `keep_results` - flag to not remove results from Redis after reading.
7373
* `result_ex_time` - expire time in seconds (by default - not specified)
7474
* `result_px_time` - expire time in milliseconds (by default - not specified)
75-
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
76-
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
75+
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
76+
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
7777
>```python
7878
># First variant
7979
>redis_async_result = RedisAsyncResultBackend(
@@ -86,4 +86,4 @@ RedisAsyncResultBackend parameters:
8686
> redis_url="redis://localhost:6379",
8787
> result_px_time=1000000,
8888
>)
89-
>```
89+
>```

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/redis_backend.py

Lines changed: 7 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,
@@ -99,7 +100,7 @@ async def is_result_ready(self, task_id: str) -> bool:
99100
async with Redis(connection_pool=self.redis_pool) as redis:
100101
return bool(await redis.exists(task_id))
101102

102-
async def get_result( # noqa: WPS210
103+
async def get_result(
103104
self,
104105
task_id: str,
105106
with_logs: bool = False,
@@ -110,6 +111,8 @@ async def get_result( # noqa: WPS210
110111
:param task_id: task's id.
111112
:param with_logs: if True it will download task's logs.
112113
:return: task's return value.
114+
115+
:raises ResultGetError: if result doesn't exist.
113116
"""
114117
async with Redis(connection_pool=self.redis_pool) as redis:
115118
if self.keep_results:
@@ -121,6 +124,9 @@ async def get_result( # noqa: WPS210
121124
name=task_id,
122125
)
123126

127+
if result_value is None:
128+
raise ResultGetError("Result doesn't exist.")
129+
124130
taskiq_result: TaskiqResult[_ReturnType] = pickle.loads(result_value)
125131

126132
if not with_logs:

tests/test_backend.py

Lines changed: 3 additions & 3 deletions
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 (
@@ -210,7 +210,7 @@ async def test_unsuccess_backend_expire_ex_param(
210210
)
211211
await asyncio.sleep(1.1)
212212

213-
with pytest.raises(TypeError):
213+
with pytest.raises(ResultGetError):
214214
await backend.get_result(task_id=task_id)
215215

216216

@@ -270,5 +270,5 @@ async def test_unsuccess_backend_expire_px_param(
270270
)
271271
await asyncio.sleep(1.1)
272272

273-
with pytest.raises(TypeError):
273+
with pytest.raises(ResultGetError):
274274
await backend.get_result(task_id=task_id)

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
@@ -2,6 +2,7 @@
22

33
import pytest
44
from taskiq import TaskiqResult
5+
from taskiq.exceptions import ResultGetError
56

67
from taskiq_redis import RedisAsyncResultBackend
78

@@ -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(ResultGetError):
9899
await result_backend.get_result(task_id=task_id)
99100

100101

0 commit comments

Comments
 (0)