fast-job-0.2.1
توضیحات
a distributed scheduled task scheduling component written for fast-api
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fast-job-0.2.1 |
| نام | fast-job |
| نسخه کتابخانه | 0.2.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Euraxluo |
| ایمیل نویسنده | euraxluo@qq.com |
| آدرس صفحه اصلی | https://github.com/Euraxluo/fast_job |
| آدرس اینترنتی | https://pypi.org/project/fast-job/ |
| مجوز | The MIT LICENSE |
### fast_job
- name = "fast_job"
- description = "Provides scheduling apis and scheduling and task-related services"
- authors = ["Euraxluo <euraxluo@qq.com>"]
- license = "The MIT LICENSE"
- repository = "https://github.com/Euraxluo/fast_job"
- coverage : 74%
- version : 0.2.*

#### install
`pip install fast-job`
#### UseAge
1.wrapper function to build task
```
from fast_job import *
@schedule.task('task1', summer="test_task_1", tag='test', description="test_task_1")
def test(tag: int):
print({"msg": "test_task_1", "tag": tag})
return {"msg": "test_task_1", "tag": tag}
@schedule.task('task2', summer="test_task_2", tag='test', description="test_task_2")
def test2(tag: int):
print({"msg": "test_task_2", "tag": tag})
return {"msg": "test_task_2", "tag": tag}
@schedule.task('task3', summer="test_task_3", tag='test', description="test_task_3")
def task3(tag: int):
raise Exception(str({"msg": "test_task_2", "tag": tag}))
```
2.include in your fastApi
```python
from loguru import logger
from fastapi import FastAPI
from example.jobs import schedule, fast_job_api_router
from example.conftest import rdb as redis
app = FastAPI()
@app.on_event("startup")
async def registry_schedule():
schedule.setup(prefix='test:', logger=logger, redis=redis, distributed=True)
@app.on_event("shutdown") # 关闭调度器
async def shutdown_connect():
schedule.shutdown()
prefix = "/test"
app.include_router(fast_job_api_router, prefix=prefix, tags=["jobs"]) # include router
```
نیازمندی
| مقدار | نام |
|---|---|
| - | redis |
| ==3.7.0 | APScheduler |
| ==1.9.0 | pydantic |
| - | fastapi |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6,<4.0 | Python |
نحوه نصب
نصب پکیج whl fast-job-0.2.1:
pip install fast-job-0.2.1.whl
نصب پکیج tar.gz fast-job-0.2.1:
pip install fast-job-0.2.1.tar.gz