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.9.tar.gz
(18.3 kB
view details)
Built Distribution
fast_job-0.1.9-py3-none-any.whl
(21.0 kB
view details)
File details
Details for the file fast_job-0.1.9.tar.gz
.
File metadata
- Download URL: fast_job-0.1.9.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.6.9 Linux/5.4.0-99-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fae10de7768b69ef3d5ee7fd682a43ce5cdc86c5896e3997822d848cb3dc5c2 |
|
MD5 | a72bef59de093759dbf8fbd10e0f6d9e |
|
BLAKE2b-256 | 4bb7c32b432e57c7746053dfb55408618c9f64217aeeedad50a10a67b4113f8f |
File details
Details for the file fast_job-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: fast_job-0.1.9-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.6.9 Linux/5.4.0-99-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 099856fce4980b2dfe9595138d352adbc57efd49e199fc44186388cae874bc5d |
|
MD5 | 714b4f75c5cadb4926963ade72593617 |
|
BLAKE2b-256 | c7e7bc056b964505ce3542bf016c4c05cf73f9326ec273850e10152277a5c37d |