fastapi-scheduler


Namefastapi-scheduler JSON
Version 0.0.13 PyPI version JSON
download
home_page
SummaryFastAPI-Scheduler is a simple scheduled task management FastAPI extension based on APScheduler.
upload_time2023-07-11 15:18:40
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords fastapi-amis-admin fastapi-apscheduler fastapi-scheduler apscheduler
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h2 align="center">
  FastAPI-Scheduler
</h2>
<p align="center">
    <a href="https://pypi.org/project/fastapi-scheduler" target="_blank">
        <img src="https://badgen.net/pypi/v/fastapi-scheduler?color=blue" alt="Package version">
    </a>
    <a href="https://pepy.tech/project/fastapi-scheduler" target="_blank">
        <img src="https://pepy.tech/badge/fastapi-scheduler" alt="Downloads">
    </a>
    <a href="https://gitter.im/amisadmin/fastapi-amis-admin">
        <img src="https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg" alt="Chat on Gitter"/>
    </a>
    <a href="https://jq.qq.com/?_wv=1027&k=U4Dv6x8W" target="_blank">
        <img src="https://badgen.net/badge/qq%E7%BE%A4/229036692/orange" alt="229036692">
    </a>
</p>
## Project Introduction

`FastAPI-Scheduler` is a simple scheduled task management `FastAPI` extension library based on `APScheduler`.

## Install

```bash
pip install fastapi-scheduler
```

## Simple example

**main.py**:

```python
from fastapi import FastAPI
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
from datetime import date
from fastapi_scheduler import SchedulerAdmin

# Create `FastAPI` application
app = FastAPI()

# Create `AdminSite` instance
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))

# # Custom timed task scheduler
# from apscheduler.schedulers.asyncio import AsyncIOScheduler
# from apscheduler.jobstores.redis import RedisJobStore
# # Use `RedisJobStore` to create a job store
# scheduler = AsyncIOScheduler(jobstores={'default':RedisJobStore(db=2,host="127.0.0.1",port=6379,password="test")})
# scheduler = SchedulerAdmin.bind(site,scheduler=scheduler)

# Create an instance of the scheduled task scheduler `SchedulerAdmin`
scheduler = SchedulerAdmin.bind(site)


# Add scheduled tasks, refer to the official documentation: https://apscheduler.readthedocs.io/en/master/
# use when you want to run the job at fixed intervals of time
@scheduler.scheduled_job('interval', seconds=60)
def interval_task_test():
    print('interval task is run...')


# use when you want to run the job periodically at certain time(s) of day
@scheduler.scheduled_job('cron', hour=3, minute=30)
def cron_task_test():
    print('cron task is run...')


# use when you want to run the job just once at a certain point of time
@scheduler.scheduled_job('date', run_date=date(2022, 11, 11))
def date_task_test():
    print('date task is run...')


@app.on_event("startup")
async def startup():
    # Mount the background management system
    site.mount_app(app)
    # Start the scheduled task scheduler
    scheduler.start()


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, debug=True)
```

## Interface/UI preview

- Open `http://127.0.0.1:8000/admin/` in your browser:

![SchedulerAdmin](https://s2.loli.net/2022/05/10/QEtCLsWi1389BKH.png)

## Dependent projects

- [FastAPI-Amis-Admin](https://docs.amis.work/)

- [APScheduler](https://apscheduler.readthedocs.io/en/master/)

## agreement

The project follows the Apache2.0 license agreement.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fastapi-scheduler",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Atomi <1456417373@qq.com>",
    "keywords": "FastAPI-Amis-Admin,FastAPI-APScheduler,fastapi-scheduler,APScheduler",
    "author": "",
    "author_email": "Atomi <1456417373@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/c2/8b/0c59bac1d2115932f8f2dcce8da3db6c5a93c811edef9df45ad7cfb6e497/fastapi_scheduler-0.0.13.tar.gz",
    "platform": null,
    "description": "<h2 align=\"center\">\n  FastAPI-Scheduler\n</h2>\n<p align=\"center\">\n    <a href=\"https://pypi.org/project/fastapi-scheduler\" target=\"_blank\">\n        <img src=\"https://badgen.net/pypi/v/fastapi-scheduler?color=blue\" alt=\"Package version\">\n    </a>\n    <a href=\"https://pepy.tech/project/fastapi-scheduler\" target=\"_blank\">\n        <img src=\"https://pepy.tech/badge/fastapi-scheduler\" alt=\"Downloads\">\n    </a>\n    <a href=\"https://gitter.im/amisadmin/fastapi-amis-admin\">\n        <img src=\"https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg\" alt=\"Chat on Gitter\"/>\n    </a>\n    <a href=\"https://jq.qq.com/?_wv=1027&k=U4Dv6x8W\" target=\"_blank\">\n        <img src=\"https://badgen.net/badge/qq%E7%BE%A4/229036692/orange\" alt=\"229036692\">\n    </a>\n</p>\n## Project Introduction\n\n`FastAPI-Scheduler` is a simple scheduled task management `FastAPI` extension library based on `APScheduler`.\n\n## Install\n\n```bash\npip install fastapi-scheduler\n```\n\n## Simple example\n\n**main.py**:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_amis_admin.admin.settings import Settings\nfrom fastapi_amis_admin.admin.site import AdminSite\nfrom datetime import date\nfrom fastapi_scheduler import SchedulerAdmin\n\n# Create `FastAPI` application\napp = FastAPI()\n\n# Create `AdminSite` instance\nsite = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))\n\n# # Custom timed task scheduler\n# from apscheduler.schedulers.asyncio import AsyncIOScheduler\n# from apscheduler.jobstores.redis import RedisJobStore\n# # Use `RedisJobStore` to create a job store\n# scheduler = AsyncIOScheduler(jobstores={'default':RedisJobStore(db=2,host=\"127.0.0.1\",port=6379,password=\"test\")})\n# scheduler = SchedulerAdmin.bind(site,scheduler=scheduler)\n\n# Create an instance of the scheduled task scheduler `SchedulerAdmin`\nscheduler = SchedulerAdmin.bind(site)\n\n\n# Add scheduled tasks, refer to the official documentation: https://apscheduler.readthedocs.io/en/master/\n# use when you want to run the job at fixed intervals of time\n@scheduler.scheduled_job('interval', seconds=60)\ndef interval_task_test():\n    print('interval task is run...')\n\n\n# use when you want to run the job periodically at certain time(s) of day\n@scheduler.scheduled_job('cron', hour=3, minute=30)\ndef cron_task_test():\n    print('cron task is run...')\n\n\n# use when you want to run the job just once at a certain point of time\n@scheduler.scheduled_job('date', run_date=date(2022, 11, 11))\ndef date_task_test():\n    print('date task is run...')\n\n\n@app.on_event(\"startup\")\nasync def startup():\n    # Mount the background management system\n    site.mount_app(app)\n    # Start the scheduled task scheduler\n    scheduler.start()\n\n\nif __name__ == '__main__':\n    import uvicorn\n\n    uvicorn.run(app, debug=True)\n```\n\n## Interface/UI preview\n\n- Open `http://127.0.0.1:8000/admin/` in your browser:\n\n![SchedulerAdmin](https://s2.loli.net/2022/05/10/QEtCLsWi1389BKH.png)\n\n## Dependent projects\n\n- [FastAPI-Amis-Admin](https://docs.amis.work/)\n\n- [APScheduler](https://apscheduler.readthedocs.io/en/master/)\n\n## agreement\n\nThe project follows the Apache2.0 license agreement.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "FastAPI-Scheduler is a simple scheduled task management FastAPI extension based on APScheduler.",
    "version": "0.0.13",
    "project_urls": {
        "FastAPI-Amis-Admin": "https://github.com/amisadmin/fastapi_amis_admin",
        "Source": "https://github.com/amisadmin/fastapi_scheduler"
    },
    "split_keywords": [
        "fastapi-amis-admin",
        "fastapi-apscheduler",
        "fastapi-scheduler",
        "apscheduler"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d52a99abf23da155a1490752f51538fc3a29f7b1335b9b4921412f90f376517",
                "md5": "6e479593ae5ac920842d7318645da8f2",
                "sha256": "eca02e38481856a35c7cdf9ed9624cdb057b99403773a317e1c74191fd431128"
            },
            "downloads": -1,
            "filename": "fastapi_scheduler-0.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e479593ae5ac920842d7318645da8f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9152,
            "upload_time": "2023-07-11T15:18:39",
            "upload_time_iso_8601": "2023-07-11T15:18:39.051848Z",
            "url": "https://files.pythonhosted.org/packages/8d/52/a99abf23da155a1490752f51538fc3a29f7b1335b9b4921412f90f376517/fastapi_scheduler-0.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c28b0c59bac1d2115932f8f2dcce8da3db6c5a93c811edef9df45ad7cfb6e497",
                "md5": "fc801557349a74aea1004bd5ec87b249",
                "sha256": "10b9b5017b705a2dac41c8b1fb48435c587d92a990935374f7659de9adf0bc09"
            },
            "downloads": -1,
            "filename": "fastapi_scheduler-0.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "fc801557349a74aea1004bd5ec87b249",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8362,
            "upload_time": "2023-07-11T15:18:40",
            "upload_time_iso_8601": "2023-07-11T15:18:40.562914Z",
            "url": "https://files.pythonhosted.org/packages/c2/8b/0c59bac1d2115932f8f2dcce8da3db6c5a93c811edef9df45ad7cfb6e497/fastapi_scheduler-0.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 15:18:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amisadmin",
    "github_project": "fastapi_amis_admin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastapi-scheduler"
}
        
Elapsed time: 0.08966s