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
Error run fastapi-mqtt using gunicorn #25
Comments
Hi, I gave a simple solution here can you check this pls and let me know. |
I try and error! |
I had the same problem. Simple uvicorn running was working well, but
or even use tiangolo/uvicorn-gunicorn-fastapi:python3.8 to run my program got the same error:
|
Was there any further thoughts on this? The error is mentioned here tiangolo/fastapi#3939. This response suggest a solution tiangolo/fastapi#3939 (comment)
|
Hope that solves this problem. 🥳 |
Closing this one as completed. In recent versions there is support for lifespan async context manager, and the The example apps work with both |
I use fastapi-mqtt==0.3.0, python==3.9.7, fastapi==0.68.1
I run example application by command : uvicorn app:app --host 0.0.0.0 --port 7000 --reload
Everything is ok -> app run
But:
I run example application by command :
gunicorn app:app -k uvicorn.workers.UvicornWorker --workers=9 -b 0.0.0.0:7000
Error :
File "/home/hoanganh/smarthome-server/venv/lib/python3.9/site-packages/gmqtt/client.py", line 230, in connect
await self._connected.wait()
File "/usr/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
RuntimeError: Task <Task pending name='Task-3' coro=<LifespanOn.main() running at /home/hoanganh/smarthome-server/venv/lib/python3.9/site-packages/uvicorn/lifespan/on.py:84>> got Future attached to a different loop
[2021-09-21 20:42:13 +0700] [10419] [ERROR] Application startup failed. Exiting.
[2021-09-21 20:42:13 +0700] [10419] [INFO] Worker exiting (pid: 10419)
Task was destroyed but it is pending!
task: <Task pending name='Task-1' coro=<Client._resend_qos_messages() running at /home/hoanganh/smarthome-server/venv/lib/python3.9/site-packages/gmqtt/client.py:176>>
sys:1: RuntimeWarning: coroutine 'Client._resend_qos_messages' was never awaited
[2021-09-21 20:42:14 +0700] [10418] [INFO] Shutting down: Master
[2021-09-21 20:42:14 +0700] [10418] [INFO] Reason: Worker failed to boot.
The text was updated successfully, but these errors were encountered: