lavkach3
1import taskiq_fastapi2from taskiq import InMemoryBroker3from taskiq_nats import NatsBroker4from taskiq_redis import RedisAsyncResultBackend5
6from fastapi_app.settings import settings7
8broker = NatsBroker(9settings.nats_urls.split(","),10queue="fastapi_app_queue",11).with_result_backend(12RedisAsyncResultBackend(settings.redis_url),13)
14
15# Actually, you can remove this line and test agains real
16# broker. Which is more preferable in some cases.
17if settings.env.lower() == "pytest":18broker = InMemoryBroker()19
20
21taskiq_fastapi.init(broker, "fastapi_app.__main__:get_app")