Catalog PyPI
Back to packageRELEASE DETAILS

0.3.0

PyPI

aioclock

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

Published18 Aug 2024
Direct dependencies5
Transitive dependenciesNot calculated

README

Version 0.3.0 documentation

aioclock

Release Build status Commit activity License

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

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 for more details.

A Sample Example

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())

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 5

Native requirements
5 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
asyncer
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
asyncer>=0.0.7runtime
croniter
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
croniter>=2.0.5runtime
fast-depends
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
fast-depends>=2.4.0runtime
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
pydantic<3.0,>2.5runtime
fastapi
Environment
{
  "extras": "",
  "marker": "extra == \"fastapi\"",
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
fastapi; extra == "fastapi"runtime

Distribution files

2 collected
aioclock-0.3.0-py3-none-any.whl

bdist_wheel · 19.11 KB · Python py3

Source file
aioclock-0.3.0.tar.gz

sdist · 1,200.55 KB · Python source

Source file

Repository

PENDING
manimozaffar/aioclock

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:44 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:353ca2d585a3111e993edd155d78007b76b24af2321262fbbdfc4e202ed1b4b3

Other collected versions

View all collected versions →