Comments (6)
The documentation is here https://fastapi.tiangolo.com/advanced/events/#async-context-manager
Can you also add that to the docs here?
from fastapi-utilities.
The functions repeat_at
and repeat_every
work for the time being after the depreciation of the alternative events like app.on_startup()
.
I'll try to figure out a solution for this issue asap. Need to add our functions in the lifespan of the app.
from fastapi-utilities.
Any update on this?
from fastapi-utilities.
This library seems exactly the right solution to my problem, but yes, exactly the same concern that it is not possible to use it with the newest version. Are there any updates or an expected time when there might be an update?
from fastapi-utilities.
I found a workaround for this.
from fastapi import FastAPI
from contextlib import asynccontextmanager
from fastapi_utilities.repeat import repeat_every, repeat_at
@asynccontextmanager
async def lifespan(app: FastAPI):
# --- startup ---
await test()
test2()
yield
# --- shutdown ---
app = FastAPI(lifespan=lifespan)
# Repeat Every Example
@repeat_every(seconds=2)
async def test():
print("test")
# Repeat At Example
@repeat_at(cron="* * * * *")
def test2():
print("test2")
This works fine.
We need to useasynccontextmanager
.
Only difference is to call our tasks from lifespan function instead of using on_event
function.
Till then please use this and let me know the reviews.
from fastapi-utilities.
I feel this solution is enough for us.
@mareksDev @cm-halfspace @vorenhoutgithub Please let me know and merge the above PR.
from fastapi-utilities.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi-utilities.