fastapi-utils: [BUG] @repeat_every blocks app startup on version 0.6.0
Describe the bug On version 0.2.1 there is no problem, but when using 0.6.0 the app doesn’t start. Attaching simple code to reproduce
To Reproduce
import logging
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
from fastapi_utils.tasks import repeat_every
logging.basicConfig(level=logging.INFO, force=True)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
await do_something()
yield
app = FastAPI(lifespan=lifespan)
@repeat_every(seconds=1, logger=logger) # 30 Minutes
async def do_something() -> None:
logger.info("Removing idle devcontainers...")
return
@app.get("/")
async def health():
return 'Success'
if __name__ == "__main__":
uvicorn.run(app, host="localhost", port=8080)
Expected behavior App should start
Environment:
- OS: Tested on Linux and Windows
- FastAPI Utils version 0.6.0
- Python version 3.11
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 20 (4 by maintainers)
Mommy always told me: lock your dependencies. But I never listened to her. Now I lost several hours on a deadline week figuring out why the server is not starting. This is very unfortunate, but a life lesson nevertheless
It should be ok when installed via
fastapi-utils[all], as [all] includes all optional dependencies including typing_inspect. Adding typing_inspect to standard install might be a good solution though.@ollz272 Sure! Here it is: #308
Same issue here.