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.1.tar.gz (3.7 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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: async_task_scheduler-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for async_task_scheduler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d90979689e8c1b7e73f0578027fcdfc2089eda81d16d3b5384028aedf6e85644
MD5 94c91de179e0a6ec361378e6bd6c3a91
BLAKE2b-256 a42a5eb96c2e8419e7dde6c9aecc0fc38547d78c7e7f7b446080e2a3ca0e9fab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for async_task_scheduler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 528817269de7aec582509e2dac2c0e5c2954f80a4a444f553fb55cc1d8c7c1bf
MD5 e38c0dfc7fd046835fb5837c3615ef9e
BLAKE2b-256 9b559cb12efadc3df2d0e14d2374ddb2c0886f7fe15f3afbba50325a429a6ca3

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