Skip to main content

An async task scheduler framework

Project description

async_task_scheduler

async_task_scheduler is a Python module that allows you to schedule asynchronous tasks using various scheduling strategies such as cron-like schedules, one-time execution, and more.

Installation

To install the module, simply install it using pip:

pip install async_task_scheduler

Usage

Creating a Scheduler

First, create an instance of the Scheduler class:

from async_task_scheduler import Scheduler

scheduler = Scheduler()

Adding Tasks

You can add tasks to the scheduler using various decorators:

Always

Runs the task every minute.

@scheduler.always
async def every_minute():
    print("This will be called every minute")

Cron

Runs the task based on a cron-like schedule.

@scheduler.cron("*/2 * * * 5")
async def custom_cron_schedule():
    print("This will be called every two minutes on Fridays")

Hourly

Runs the task at the start of every hour.

@scheduler.hourly
async def every_hour():
    print("This will be called every hour")

Daily

Runs the task at the start of every day.

@scheduler.daily
async def every_day():
    print("This will be called every day")

Weekly

Runs the task at the start of every week.

@scheduler.weekly
async def every_week():
    print("This will be called every week")

Monthly

Runs the task at the start of every month.

@scheduler.monthly
async def every_month():
    print("This will be called every month")

At Start

Runs the task once when the scheduler starts.

@scheduler.at_start
async def start_task():
    print("This will be called once when the scheduler starts")

At Specific Time

Runs the task at a specific datetime.

@scheduler.at(datetime(2025, 3, 10, 18, 29))
async def future_task():
    print("This will be called at 6:29 PM on March 10, 2025")

Running the Scheduler

To run the scheduler, await the run method or call it using asyncio.run:

await scheduler.run()

or

import asyncio

asyncio.run(scheduler.run())

The scheduler will run indefinitely until the program is stopped.

Example

See the end of the source file for a complete example.

License

This project is licensed under the MIT License.

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

async_task_scheduler-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_task_scheduler-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file async_task_scheduler-0.1.2.tar.gz.

File metadata

  • Download URL: async_task_scheduler-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for async_task_scheduler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 82903228b980fdb83cdce015a892b3561daf39da3d72f124673ae890e3f29d0a
MD5 9b026194db51a6503309237fc34aca47
BLAKE2b-256 8d01fe218519d84d5055d5bfa014d161e975c935ed8ec6c377456ec59b48f97a

See more details on using hashes here.

File details

Details for the file async_task_scheduler-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: async_task_scheduler-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for async_task_scheduler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93d8e9f1f861d2f264d56580712fc2f8e75151c19e32459d8a298029bdb7b44b
MD5 32ba78fb709269f38fc07866e0609dd0
BLAKE2b-256 382995039b2d6ad3a18a497b1edf2cb075fdd1caefb85e431b7f33bf98bd0e25

See more details on using hashes here.

Supported by

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