a distributed scheduled task scheduling component written for fast-api
Project description
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.1.*
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fast_job-0.1.13.tar.gz
(18.4 kB
view details)
Built Distribution
fast_job-0.1.13-py3-none-any.whl
(21.1 kB
view details)
File details
Details for the file fast_job-0.1.13.tar.gz
.
File metadata
- Download URL: fast_job-0.1.13.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-104-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d156aea2f6be5e8cb236aa70b4d41470c2715724a499e2466d6d9170074639ea |
|
MD5 | 82cb087c40c47c8821ba03108a936e03 |
|
BLAKE2b-256 | c5935fb6f12cecb76917aa4afe7436a9493ee5abca0f035d6f17f784d99857eb |
File details
Details for the file fast_job-0.1.13-py3-none-any.whl
.
File metadata
- Download URL: fast_job-0.1.13-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-104-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5db5dcf836267a51102c7957b3f3ffaae912267a33a747292d4207c2edc5ee0 |
|
MD5 | 59a5dc0e2e9690072e0dc56b03d3e4ec |
|
BLAKE2b-256 | f4b330a39026ee7a0c94c069b73c98ffee08953d7191b046a5760cea7cfdc471 |