添加定时任务配置
This commit is contained in:
7
scheduler/__init__.py
Normal file
7
scheduler/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastscheduler.fastapi_integration import create_scheduler_routes
|
||||
from scheduler.scheduler import scheduler
|
||||
|
||||
def init_scheduler_router(app : FastAPI):
|
||||
app.include_router(create_scheduler_routes(scheduler))
|
||||
scheduler.start()
|
||||
@@ -0,0 +1,9 @@
|
||||
from fastscheduler import FastScheduler
|
||||
|
||||
|
||||
scheduler = FastScheduler(quiet=True)
|
||||
|
||||
|
||||
@scheduler.every(10).seconds
|
||||
def background_task():
|
||||
print("Background work")
|
||||
Reference in New Issue
Block a user