fastapi_scheduler


Namefastapi_scheduler JSON
Version 0.0.15 PyPI version JSON
download
home_page
SummaryFastAPI-Scheduler is a simple scheduled task management FastAPI extension based on APScheduler.
upload_time2023-12-17 02:15:43
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/de/01/d32b190ad2901663a59cf4b0d9dbc567616cf1412bdac787e496775cf275/fastapi_scheduler-0.0.15.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.15",
    "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": "987fa32cb7d2cb3e8ac20591509f1a442cae5a67bc3074c63ec186162e175c89",
                "md5": "29b2371f39144424e79d81faa2fc20a3",
                "sha256": "704793fda16f948c18dca32ba77aefee7bb762dac55beaf5e7a4224e12bb3a4b"
            },
            "downloads": -1,
            "filename": "fastapi_scheduler-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29b2371f39144424e79d81faa2fc20a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9177,
            "upload_time": "2023-12-17T02:15:42",
            "upload_time_iso_8601": "2023-12-17T02:15:42.201125Z",
            "url": "https://files.pythonhosted.org/packages/98/7f/a32cb7d2cb3e8ac20591509f1a442cae5a67bc3074c63ec186162e175c89/fastapi_scheduler-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de01d32b190ad2901663a59cf4b0d9dbc567616cf1412bdac787e496775cf275",
                "md5": "64bfc0b49149ef7bc576e066fcda0330",
                "sha256": "48dc1201ee13f0cff5c19c45f6180043205d9a48cb0a5940256d8fc299d74d23"
            },
            "downloads": -1,
            "filename": "fastapi_scheduler-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "64bfc0b49149ef7bc576e066fcda0330",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8399,
            "upload_time": "2023-12-17T02:15:43",
            "upload_time_iso_8601": "2023-12-17T02:15:43.961475Z",
            "url": "https://files.pythonhosted.org/packages/de/01/d32b190ad2901663a59cf4b0d9dbc567616cf1412bdac787e496775cf275/fastapi_scheduler-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-17 02:15:43",
    "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: 2.38354s