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
{{ message }}
This repository was archived by the owner on Nov 10, 2024. It is now read-only.
Describe the bug
If you use the repeat_every decorator without app.on_event("startup"), it requires calling in an async context to actually add to loop to asyncio. You can also get it to work by awaiting the resulting decorated function after the fact.
from fastapi_restful.tasks import repeat_every
@repeat_every(seconds=60)
def do_stuff():
""" this is never called """
It must be called from an async context
from fastapi import FastAPI
from fastapi_restful.tasks import repeat_every
app = FastAPI()
@app.on_event("startup") # runs the decoration once, adding the loop to asyncio
@repeat_every(seconds=60)
def do_stuff():
""" this is never called """
Expected behavior
The decorated function is repeatedly called without
Environment:
OS: Any (I repro'd on Linux)
FastAPI Utils, FastAPI, and Pydantic versions [e.g. 0.3.0], get them with: