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)

Most upvoted comments

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

I can confirm what @RamiAwar commented. It still is an issue on 0.7.0. Though, I think it’s not related to the original issue, but rather just to this comment, for which there is a separate issue: #318.

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.

    from fastapi_utils.tasks import repeat_every
  File "/home/iheredia/anaconda3/lib/python3.8/site-packages/fastapi_utils/__init__.py", line 4, in <module>
    from .cbv_base import Api, Resource, set_responses, take_init_parameters
  File "/home/iheredia/anaconda3/lib/python3.8/site-packages/fastapi_utils/cbv_base.py", line 5, in <module>
    from .cbv import INCLUDE_INIT_PARAMS_KEY, RETURN_TYPES_FUNC_KEY, _cbv
  File "/home/iheredia/anaconda3/lib/python3.8/site-packages/fastapi_utils/cbv.py", line 21, in <module>
    from typing_inspect import is_classvar
ModuleNotFoundError: No module named 'typing_inspect'