aioclock


Nameaioclock JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryAn asyncio-based scheduling framework designed for execution of periodic task with integrated support for dependency injection, enabling efficient and flexible task management
upload_time2024-08-18 18:46:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aioclock

[![Release](https://img.shields.io/github/v/release/ManiMozaffar/aioclock)](https://img.shields.io/github/v/release/ManiMozaffar/aioclock)
[![Build status](https://img.shields.io/github/actions/workflow/status/ManiMozaffar/aioclock/main.yml?branch=main)](https://github.com/ManiMozaffar/aioclock/actions/workflows/main.yml?query=branch%3Amain)
[![Commit activity](https://img.shields.io/github/commit-activity/m/ManiMozaffar/aioclock)](https://img.shields.io/github/commit-activity/m/ManiMozaffar/aioclock)
[![License](https://img.shields.io/github/license/ManiMozaffar/aioclock)](https://img.shields.io/github/license/ManiMozaffar/aioclock)

An asyncio-based scheduling framework designed for execution of periodic task with integrated support for dependency injection, enabling efficient and flexiable task management

- **Github repository**: <https://github.com/ManiMozaffar/aioclock/>

## Features

Aioclock offers:

- Async: 100% Async, very light, fast and resource friendly
- Scheduling: Keep scheduling tasks for you
- Group: Group your task, for better code maintainability
- Trigger: Already defined and easily extendable triggers, to trigger your scheduler to be started
- Easy syntax: Library's syntax is very easy and enjoyable, no confusing hierarchy
- Pydantic v2 validation: Validate all your trigger on startup using pydantic 2. Fastest to fail possible!
- **Soon**: Running the task dispatcher (scheduler) on different process by default, so CPU intensive stuff on task won't delay the scheduling
- **Soon**: Backend support, to allow horizontal scalling, by synchronizing, maybe using Redis

## Getting started

To Install aioclock, simply do

```
pip install aioclock
```

## Help

See [documentation](https://ManiMozaffar.github.io/aioclock/) for more details.

## A Sample Example

```python
import asyncio

from aioclock import AioClock, At, Depends, Every, Forever, Once, OnShutDown, OnStartUp
from aioclock.group import Group

# groups.py
group = Group()


def more_useless_than_me():
    return "I'm a dependency. I'm more useless than a screen door on a submarine."


@group.task(trigger=Every(seconds=10))
async def every():
    print("Every 10 seconds, I make a quantum leap. Where will I land next?")


@group.task(trigger=Every(seconds=5))
def even_sync_works():
    print("I'm a synchronous task. I work even in async world.")


@group.task(trigger=At(tz="UTC", hour=0, minute=0, second=0))
async def at():
    print(
        "When the clock strikes midnight... I turn into a pumpkin. Just kidding, I run this task!"
    )


@group.task(trigger=Forever())
async def forever(val: str = Depends(more_useless_than_me)):
    await asyncio.sleep(2)
    print("Heartbeat detected. Still not a zombie. Will check again in a bit.")
    assert val == "I'm a dependency. I'm more useless than a screen door on a submarine."


@group.task(trigger=Once())
async def once():
    print("Just once, I get to say something. Here it goes... I love lamp.")


# app.py
app = AioClock()
app.include_group(group)


@app.task(trigger=OnStartUp())
async def startup():
    print(
        "Welcome to the Async Chronicles! Did you know a group of unicorns is called a blessing? Well, now you do!"
    )


@app.task(trigger=OnShutDown())
async def shutdown():
    print("Going offline. Remember, if your code is running, you better go catch it!")


# main.py
if __name__ == "__main__":
    asyncio.run(app.serve())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aioclock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Mani Mozaffar <mani.mozaffar@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9b/58/6960028c9528c2b9fcd5fc45beadcc9e705d6009551b86b4331c51478070/aioclock-0.3.0.tar.gz",
    "platform": null,
    "description": "# aioclock\n\n[![Release](https://img.shields.io/github/v/release/ManiMozaffar/aioclock)](https://img.shields.io/github/v/release/ManiMozaffar/aioclock)\n[![Build status](https://img.shields.io/github/actions/workflow/status/ManiMozaffar/aioclock/main.yml?branch=main)](https://github.com/ManiMozaffar/aioclock/actions/workflows/main.yml?query=branch%3Amain)\n[![Commit activity](https://img.shields.io/github/commit-activity/m/ManiMozaffar/aioclock)](https://img.shields.io/github/commit-activity/m/ManiMozaffar/aioclock)\n[![License](https://img.shields.io/github/license/ManiMozaffar/aioclock)](https://img.shields.io/github/license/ManiMozaffar/aioclock)\n\nAn asyncio-based scheduling framework designed for execution of periodic task with integrated support for dependency injection, enabling efficient and flexiable task management\n\n- **Github repository**: <https://github.com/ManiMozaffar/aioclock/>\n\n## Features\n\nAioclock offers:\n\n- Async: 100% Async, very light, fast and resource friendly\n- Scheduling: Keep scheduling tasks for you\n- Group: Group your task, for better code maintainability\n- Trigger: Already defined and easily extendable triggers, to trigger your scheduler to be started\n- Easy syntax: Library's syntax is very easy and enjoyable, no confusing hierarchy\n- Pydantic v2 validation: Validate all your trigger on startup using pydantic 2. Fastest to fail possible!\n- **Soon**: Running the task dispatcher (scheduler) on different process by default, so CPU intensive stuff on task won't delay the scheduling\n- **Soon**: Backend support, to allow horizontal scalling, by synchronizing, maybe using Redis\n\n## Getting started\n\nTo Install aioclock, simply do\n\n```\npip install aioclock\n```\n\n## Help\n\nSee [documentation](https://ManiMozaffar.github.io/aioclock/) for more details.\n\n## A Sample Example\n\n```python\nimport asyncio\n\nfrom aioclock import AioClock, At, Depends, Every, Forever, Once, OnShutDown, OnStartUp\nfrom aioclock.group import Group\n\n# groups.py\ngroup = Group()\n\n\ndef more_useless_than_me():\n    return \"I'm a dependency. I'm more useless than a screen door on a submarine.\"\n\n\n@group.task(trigger=Every(seconds=10))\nasync def every():\n    print(\"Every 10 seconds, I make a quantum leap. Where will I land next?\")\n\n\n@group.task(trigger=Every(seconds=5))\ndef even_sync_works():\n    print(\"I'm a synchronous task. I work even in async world.\")\n\n\n@group.task(trigger=At(tz=\"UTC\", hour=0, minute=0, second=0))\nasync def at():\n    print(\n        \"When the clock strikes midnight... I turn into a pumpkin. Just kidding, I run this task!\"\n    )\n\n\n@group.task(trigger=Forever())\nasync def forever(val: str = Depends(more_useless_than_me)):\n    await asyncio.sleep(2)\n    print(\"Heartbeat detected. Still not a zombie. Will check again in a bit.\")\n    assert val == \"I'm a dependency. I'm more useless than a screen door on a submarine.\"\n\n\n@group.task(trigger=Once())\nasync def once():\n    print(\"Just once, I get to say something. Here it goes... I love lamp.\")\n\n\n# app.py\napp = AioClock()\napp.include_group(group)\n\n\n@app.task(trigger=OnStartUp())\nasync def startup():\n    print(\n        \"Welcome to the Async Chronicles! Did you know a group of unicorns is called a blessing? Well, now you do!\"\n    )\n\n\n@app.task(trigger=OnShutDown())\nasync def shutdown():\n    print(\"Going offline. Remember, if your code is running, you better go catch it!\")\n\n\n# main.py\nif __name__ == \"__main__\":\n    asyncio.run(app.serve())\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An asyncio-based scheduling framework designed for execution of periodic task with integrated support for dependency injection, enabling efficient and flexible task management",
    "version": "0.3.0",
    "project_urls": {
        "Documentation": "https://github.com/ManiMozaffar/aioclock",
        "Homepage": "https://github.com/ManiMozaffar/aioclock",
        "Source": "https://github.com/ManiMozaffar/aioclock",
        "repository": "https://github.com/ManiMozaffar/aioclock"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fedf3cd1ad1fda9358dd9864fd4beea7350f35b39160b88a7fea8ff0657fed9",
                "md5": "c29c721eed4c7ee5320834eebe29a3d2",
                "sha256": "3cd99b5e06d9a994696205658e574688331c64f017571a0b5410a5a7087be99e"
            },
            "downloads": -1,
            "filename": "aioclock-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c29c721eed4c7ee5320834eebe29a3d2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19567,
            "upload_time": "2024-08-18T18:46:19",
            "upload_time_iso_8601": "2024-08-18T18:46:19.760958Z",
            "url": "https://files.pythonhosted.org/packages/9f/ed/f3cd1ad1fda9358dd9864fd4beea7350f35b39160b88a7fea8ff0657fed9/aioclock-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b586960028c9528c2b9fcd5fc45beadcc9e705d6009551b86b4331c51478070",
                "md5": "035d9a5538639da539585c53d45a6ee6",
                "sha256": "ed992fc3e426c769e59feb0860b4e4a17f126471cc518c1d37dccbfa248d2134"
            },
            "downloads": -1,
            "filename": "aioclock-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "035d9a5538639da539585c53d45a6ee6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1229364,
            "upload_time": "2024-08-18T18:46:21",
            "upload_time_iso_8601": "2024-08-18T18:46:21.066950Z",
            "url": "https://files.pythonhosted.org/packages/9b/58/6960028c9528c2b9fcd5fc45beadcc9e705d6009551b86b4331c51478070/aioclock-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 18:46:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ManiMozaffar",
    "github_project": "aioclock",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "aioclock"
}
        
Elapsed time: 2.58221s