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.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
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.2.1.tar.gz
(16.7 kB
view details)
Built Distribution
fast_job-0.2.1-py3-none-any.whl
(20.0 kB
view details)
File details
Details for the file fast_job-0.2.1.tar.gz
.
File metadata
- Download URL: fast_job-0.2.1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b1 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd3c6a05b5d0c4f1173cb54781773eebcb4f13ab34fe349e52215bc7d55e651a |
|
MD5 | ecd15a7c53253e0c52df6ce40cfa006b |
|
BLAKE2b-256 | e02d60ec9029cf2eaca99a6d82337ec76e0ba4ac577aa958675686381fdf81c4 |
File details
Details for the file fast_job-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: fast_job-0.2.1-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b1 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ace459d70e3085d2745a867712bacc380eb978ccae8cc48c35ec50419fd0fd66 |
|
MD5 | 2f124f5270b5d128e66fb6f8dd771323 |
|
BLAKE2b-256 | 0fc14ed82fc65dd86067ba70dabac50de25b427b09513078e7561cb3866c204b |