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
Trying to run example with asyncrepeat_at function.
from fastapi import FastAPI
from contextlib import asynccontextmanager
from fastapi_utilities import repeat_every, repeat_at
@asynccontextmanager
async def lifespan(app: FastAPI):
# --- startup ---
await test()
await test2() # ------------- await added here
yield
# --- shutdown ---
app = FastAPI(lifespan=lifespan)
# Repeat Every Example
@repeat_every(seconds=2)
async def test():
print("test")
# Repeat At Example
@repeat_at(cron="* * * * *")
async def test2(): # ------------- async added here
print("test2")
After executing command fastapi dev main.py I got this error:
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File "C:\workspace\Learning\FastAPI\.venv\Lib\site-packages\starlette\routing.py", line 732, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "C:\workspace\Learning\FastAPI\main.py", line 11, in lifespan
await test2() # ------------- await added here
^^^^^^^^^^^^^
TypeError: object NoneType can't be used in 'await' expression
test
ERROR: Application startup failed. Exiting.
versions:
fastapi 0.111.0
fastapi-utilities 0.2.0
The text was updated successfully, but these errors were encountered:
Trying to run example with async
repeat_at
function.After executing command
fastapi dev main.py
I got this error:versions:
fastapi 0.111.0
fastapi-utilities 0.2.0
The text was updated successfully, but these errors were encountered: