taskiq-python / taskiq-redis

Broker and result backend for taskiq
MIT License
37 stars 18 forks source link

TaskiqDeprecationWarning: use `with_result_backend` #71

Open tito opened 5 hours ago

tito commented 5 hours ago

Using taskiq 0.11.7 and taskiq-redis 1.0.2, i have this deprecation warning showing up:

/.venv/lib/python3.10/site-packages/taskiq_redis/redis_broker.py:49: TaskiqDeprecationWarning: Setting result backend with constructor is deprecated. Please use `with_result_backend` instead.

The code that triggered it:

from taskiq_redis import ListQueueBroker, RedisAsyncResultBackend

from app.core.config import settings

redis_async_result = RedisAsyncResultBackend(redis_url=settings.REDIS_URL)

broker = ListQueueBroker(
    url=settings.REDIS_URL,
    result_backend=redis_async_result,
)
CurstinJR commented 5 hours ago

I guess the github docs for this repo hasn't been updated yet. There is a with_result_backend method on ListQueueBroker as well.

from this doc: https://taskiq-python.github.io/guide/getting-started.html#distributed-run

from taskiq_aio_pika import AioPikaBroker
from taskiq_redis import RedisAsyncResultBackend

broker = AioPikaBroker(
    "amqp://guest:guest@localhost:5672",
).with_result_backend(RedisAsyncResultBackend("redis://localhost"))

@tito