FastAPI-Scheduler
项目介绍
FastAPI-Scheduler是一个基于APScheduler的简单定时任务管理FastAPI拓展库.
安装
pip install fastapi-scheduler
简单示例
main.py:
from fastapi import FastAPI
from fastapi_amis_admin.amis_admin.settings import Settings
from fastapi_amis_admin.amis_admin.site import AdminSite
from datetime import date
from fastapi_scheduler import SchedulerAdmin
# 创建`FastAPI`应用
app = FastAPI()
# 创建`AdminSite`实例
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///admisadmin.db'))
# 创建定时任务调度器`SchedulerAdmin`实例
scheduler = SchedulerAdmin.bind(site)
# 添加定时任务,参考官方文档: https://apscheduler.readthedocs.io/en/master/
# use when you want to run the job at fixed intervals of time
@scheduler.scheduled_job('interval', seconds=60)
def interval_task_test():
print('interval task is run...')
# use when you want to run the job periodically at certain time(s) of day
@scheduler.scheduled_job('cron', hour=3, minute=30)
def cron_task_test():
print('cron task is run...')
# use when you want to run the job just once at a certain point of time
@scheduler.scheduled_job('date', run_date=date(2022, 11, 11))
def date_task_test():
print('date task is run...')
# 挂载后台管理系统
site.mount_app(app)
@app.on_event("startup")
async def startup():
# 启动定时任务调度器
scheduler.start()
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, debug=True)
界面预览
- Open
http://127.0.0.1:8000/admin/in your browser:
依赖项目
许可协议
该项目遵循 Apache2.0 许可协议。
Metadata
Release files for fastapi_scheduler 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_scheduler-0.0.4.tar.gz | 6.3 kB | Without provenance | Details for fastapi_scheduler-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_scheduler-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for fastapi_scheduler-0.0.4-py3-none-any.whl |
Total release size: 11.8 kB
Release files / fastapi_scheduler-0.0.4.tar.gz
| Download URL | fastapi_scheduler-0.0.4.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51208cc9cfcb19d38e7272a083f3431e1f6d10f587f9c5eb0940c90c1fde9713
|
|
BLAKE2b-256 checksum How to use checksums |
000a96142ea38711f0541db525b87e1779cf03ca1ad75516e7308bceee173da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Release files / fastapi_scheduler-0.0.4-py3-none-any.whl
| Download URL | fastapi_scheduler-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8b12e8205719e851c491fb8a773f58b1064a569220040522722400887e30385
|
|
BLAKE2b-256 checksum How to use checksums |
f016eab3f4d6c829fa18029d39c3396c77b4fcbcbe82a7a17aed283b12e9a675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Security for fastapi_scheduler 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.