Skip to content

[BUG] @repeat_every blocks app startup on version 0.6.0 #305

@jonathanhar

Description

@jonathanhar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions