core
core copied to clipboard
[BUG] Startup process processed twice
Describe the bug The startup process in main.py is being executed twice.
To Reproduce
- Add
print("STARTING", __name__)in the main.py file just after the imports - Run the application
- In the console you should see the following:
cheshire_cat_core | STARTING __main__
cheshire_cat_core | STARTING cat.main
Additional context uvicorn.run() is importing main.py again, causing the startup process to be triggered twice:
uvicorn.run(
"cat.main:cheshire_cat_api",
host="0.0.0.0",
port=80,
use_colors=True,
log_level=get_env("CCAT_LOG_LEVEL").lower(),
**debug_config,
**proxy_pass_config,
)
Should we change with fastapi-cli??
Maybe something simpler, just move the cheshire_cat_api FastAPI initialization to a separate file, and keep only the uvicorn.run in main.
Something like this? https://github.com/sambarza/test-fastapi-cors
Thanks never realized it was running twice XD
Merging soon