Skip to main content

a distributed scheduled task scheduling component written for fast-api

Project description

fast_job

test-report

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


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.10.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

fast_job-0.1.10-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file fast_job-0.1.10.tar.gz.

File metadata

  • Download URL: fast_job-0.1.10.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-100-generic

File hashes

Hashes for fast_job-0.1.10.tar.gz
Algorithm Hash digest
SHA256 01173d50cfaf5e803052c3b88d13ef5fb156f09dbd5e7f6bde031cd564e00c70
MD5 d1c9016d5b5f63492f8a9e946bdbc437
BLAKE2b-256 eaf1feae1199e96f1fe7dd1a86020717e543aa69ee2bcc25a2c5ef2b0fccf48d

See more details on using hashes here.

File details

Details for the file fast_job-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: fast_job-0.1.10-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-100-generic

File hashes

Hashes for fast_job-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fdf3bd78c43ab50038708f87f9c814cd8710c625319b86f4f66094692fb688c7
MD5 7690519814e58ea4ec492ab6c54646c3
BLAKE2b-256 93644468d125f61aaed3634391eba945f740e4933d4a748dea5e31a37c39e564

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page