You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i use fastapi + beanie, everything works perfect when running with uvicorn,
it raise RuntimeError(maybe cause by asyncio?) when using gunicorn to get more worker
i use uvicorn web_boost:app --host 127.0.0.1 --port 3344 --reload on dev env,
use gunicorn web_boost:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:3344 when error raise
i use fastapi lifespan method to init model, here is my code:
ERROR 2022-04-24 11:15:28.052 - uvicorn.lifespan.on:send - Traceback (most recent call last):
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/starlette/routing.py", line 621, in lifespan
async with self.lifespan_context(app):
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/starlette/routing.py", line 518, in __aenter__
await self._router.startup()
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/starlette/routing.py", line 598, in startup
await handler()
File "/home/zeara/proj/platform/app/core/boost.py", line 85, in boost_beanie
await init_beanie(database=_db, document_models=__beanie_models__)
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/utils/general.py", line 76, in init_beanie
await asyncio.gather(*collection_inits)
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/documents.py", line 1126, in init_model
await cls.init_settings(
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/documents.py", line 1093, in init_settings
cls._document_settings = await DocumentSettings.init(
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/settings/general.py", line 17, in init
collection_settings = await CollectionSettings.init(
File "/home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/settings/collection.py", line 71, in init
build_info = await database.command({"buildInfo": 1})
RuntimeError: Task <Task pending name='Task-3' coro=<Document.init_model() running at /home/zeara/miniconda3/envs/lunar/lib/python3.8/site-packages/beanie/odm/documents.py:1126> cb=[gather.<locals>._done_callback() at /home/zeara/miniconda3/envs/lunar/lib/python3.8/asyncio/tasks.py:769]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /home/zeara/miniconda3/envs/lunar/lib/python3.8/asyncio/futures.py:360]> attached to a different loop
ERROR 2022-04-24 11:15:28.052 - uvicorn.lifespan.on:startup - Application startup failed. Exiting.
[2022-04-24 11:15:28 +0800] [15190] [INFO] Worker exiting (pid: 15190)
[2022-04-24 11:15:28 +0800] [15185] [WARNING] Worker with pid 15189 was terminated due to signal 15
[2022-04-24 11:15:28 +0800] [15185] [WARNING] Worker with pid 15187 was terminated due to signal 15
[2022-04-24 11:15:28 +0800] [15185] [WARNING] Worker with pid 15190 was terminated due to signal 15
The text was updated successfully, but these errors were encountered:
i use fastapi + beanie, everything works perfect when running with
uvicorn
,it raise RuntimeError(maybe cause by asyncio?) when using
gunicorn
to get more workeri use
uvicorn web_boost:app --host 127.0.0.1 --port 3344 --reload
on dev env,use
gunicorn web_boost:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:3344
when error raisei use fastapi lifespan method to init model, here is my code:
the error logs here:
The text was updated successfully, but these errors were encountered: