Closed tonquangkhai closed 1 year ago
Hi and thanks raising this issue. This is because of the recent taskiq updates. To enable reload, please enable reload extra in pyproject.toml. Like this:
taskiq = {version = "^0", extras = ["reload"] }
Hope it helps.
I will leave this issue open untill we add this extra in dev group of pyproject.toml for new projects.
Also, taskiq-kafka is a relatively new project, so we haven't added support for it in fastapi-template. To use it, please check the readme in this repo: https://github.com/taskiq-python/taskiq-aio-kafka
Hi, I'll try to fix in my local. Thank you so much for your reply.
Due to the Kafka container starting very slowly so the connection between the fast-API container and the taskiq-worker with Kafka can not be established. Here are my solutions and you can choose one of them:
Increase timeout to 600s or more in docker-compose.yaml like this
healthcheck: test: kafka-topics.sh --list --bootstrap-server localhost:9092 interval: 1s timeout: 1000s retries: 10
Disable health check in both Fast-API and manually restart ONLY Fast-API when Kafka successfully started.
Remove this line
kafka: condition: service_healthy
Here is my docker-compose example.
docker-compose.md
Good luck and cheers.
Hi, @linhdmn. Thanks for your reply. But the problem was not in kafka or healthchecks. It was because of taskiq library was not installed properly. The template is fixed now in version https://github.com/s3rius/FastAPI-template/releases/tag/4.1.2.
@tonquangkhai, can you try generating project with updated version and check if everything is working?
Currently everything worked fine in 4.1.2 but I am not adding kafka support option yet.
And also the command
taskiq-worker in docker-compose.dev.yml is not fixed so it will cause small error when user try to build up in the dev enviroment. But overall everything is ok for now.
I will close this Issue since the project can be generated and worked well on new version 4.1.2. Just a small issue related to docker-compose.dev.yml if you guys need to using taskiq in local dev enviroment please reference to docker-compose.yml in the same folder, change <your_project_name>.taskiq:broker
--> <your_project_name>.tkq:broker
. Also if you choose to init kafka with the project you should increase timeout in healthcheck to 300s (more or less depend on your computer) so the project will start normally. Thank @linhdmn for pointing this.
Hi Pavel Kirilin, I recently generated a FastAPI project from your template and I really like it. However, when I tried to build the project on my local machine (Macbook with Intel chip) using Docker Compose, I encountered an error related to adding TaskIQ support. I tried to fix it on my own, but unfortunately, I was not successful. Could you please help me with this issue?
Traceback (most recent call last):
File "/usr/local/bin/taskiq", line 8, in
File "/usr/local/lib/python3.9/site-packages/taskiq/main.py", line 72, in main
File "/usr/local/lib/python3.9/site-packages/taskiq/cli/worker/cmd.py", line 26, in exec
File "/usr/local/lib/python3.9/site-packages/taskiq/cli/worker/run.py", line 144, in run_worker
ValueError: To use '--reload' flag, please install 'taskiq[reload]'.```
Thank for reading this :)