Skip to content

Updated dependencies, fixed errors. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- 6379:6379
strategy:
matrix:
py_version: ["3.7", "3.8", "3.9", "3.10"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ RedisAsyncResultBackend parameters:
* `keep_results` - flag to not remove results from Redis after reading.
* `result_ex_time` - expire time in seconds (by default - not specified)
* `result_px_time` - expire time in milliseconds (by default - not specified)
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
> IMPORTANT: **It is highly recommended to use expire time ​​in RedisAsyncResultBackend**
> If you want to add expiration, either `result_ex_time` or `result_px_time` must be set.
>```python
># First variant
>redis_async_result = RedisAsyncResultBackend(
Expand All @@ -93,4 +93,4 @@ RedisAsyncResultBackend parameters:
> redis_url="redis://localhost:6379",
> result_px_time=1000000,
>)
>```
>```
724 changes: 288 additions & 436 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ repository = "https://github.com/taskiq-python/taskiq-redis"
keywords = ["taskiq", "tasks", "distributed", "async", "redis", "result_backend"]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8.1"
taskiq = "^0"
redis = "^4.2.0"

[tool.poetry.dev-dependencies]
pytest = "^7.0"
flake8 = "^4.0.1"
flake8 = "^6"
mypy = "^0.961"
isort = "^5.10.1"
yesqa = "^1.3.0"
wemake-python-styleguide = "^0.16.1"
wemake-python-styleguide = "^0.18"
black = "^22.3.0"
autoflake = "^1.4"
pytest-cov = "^3.0.0"
Expand Down
11 changes: 7 additions & 4 deletions taskiq_redis/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
class TaskIQRedisError(Exception):
from taskiq.exceptions import ResultBackendError, ResultGetError, TaskiqError


class TaskIQRedisError(TaskiqError):
"""Base error for all taskiq-redis exceptions."""


class DuplicateExpireTimeSelectedError(TaskIQRedisError):
class DuplicateExpireTimeSelectedError(ResultBackendError, TaskIQRedisError):
"""Error if two lifetimes are selected."""


class ExpireTimeMustBeMoreThanZeroError(TaskIQRedisError):
class ExpireTimeMustBeMoreThanZeroError(ResultBackendError, TaskIQRedisError):
"""Error if two lifetimes are less or equal zero."""


class ResultIsMissingError(TaskIQRedisError):
class ResultIsMissingError(TaskIQRedisError, ResultGetError):
"""Error if there is no result when trying to get it."""
2 changes: 1 addition & 1 deletion taskiq_redis/redis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def is_result_ready(self, task_id: str) -> bool:
async with Redis(connection_pool=self.redis_pool) as redis:
return bool(await redis.exists(task_id))

async def get_result( # noqa: WPS210
async def get_result(
self,
task_id: str,
with_logs: bool = False,
Expand Down
7 changes: 5 additions & 2 deletions tests/test_broker.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import asyncio
import uuid
from typing import Union

import pytest
from taskiq import AsyncBroker, BrokerMessage
from taskiq import AckableMessage, AsyncBroker, BrokerMessage

from taskiq_redis import ListQueueBroker, PubSubBroker


async def get_message(broker: AsyncBroker) -> bytes: # type: ignore
async def get_message( # type: ignore
broker: AsyncBroker,
) -> Union[bytes, AckableMessage]:
"""
Get a message from the broker.

Expand Down
3 changes: 2 additions & 1 deletion tests/test_result_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from taskiq import TaskiqResult

from taskiq_redis import RedisAsyncResultBackend
from taskiq_redis.exceptions import ResultIsMissingError


@pytest.mark.anyio
Expand Down Expand Up @@ -94,7 +95,7 @@ async def test_remove_results_after_reading(redis_url: str) -> None:
)

await result_backend.get_result(task_id=task_id)
with pytest.raises(Exception):
with pytest.raises(ResultIsMissingError):
await result_backend.get_result(task_id=task_id)


Expand Down