Async crontab like scheduler
Project description
Introduction
This is an asynchronous job scheduler with crontab syntax.
How to use
Here is a basic example
# Should run as-is
import time
import asyncio
from typing import Any
from functools import partial
from timewheel import TimeWheel
from timewheel.schedule import Schedule
async def my_job():
print("hello from job!")
await asyncio.sleep(3)
async def my_another_job(some_value: Any):
print(f"Hey! This is my some_value {some_value}")
await asyncio.sleep(1)
def my_sync_job():
print("Hello from the sync job")
time.sleep(10)
async def main():
timewheel = TimeWheel(schedules=[
# Runs every 29 minutes
Schedule("my-schedule", "*/29 * * * *", my_job),
# Runs every 5th, 10th and 20th minute on wednesday
Schedule("another-schedule", "5,10,20 * * * 2", my_job),
# Runs every 10 minutes
Schedule("my-schedyle-with-fixed-param", "*/10 * * * *", partial(my_another_job,
{"some_value": "My value"})),
# Runs every minute
Schedule("a-sync-job", "* * * * *", my_sync_job)])
await timewheel.run()
asyncio.get_event_loop().run_until_complete(main())
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
Built Distribution
Close
Hashes for timewheel-scheduler-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65eae47c475d22e2f580f7cf2c0dc9cf29047f169eb7c739a5b65795e3ab2dcd |
|
MD5 | 82ed58d14172a545e7b3c5411cfe1b96 |
|
BLAKE2b-256 | 897b71b73f801bdfd06e8e2094d9c4822f798ea75a7c5fb8f76859f7220af2ae |
Close
Hashes for timewheel_scheduler-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09857103127fecab0cc7b270071e3faf0ab90c6b183bf4812a814d8d1c3b3b70 |
|
MD5 | 01800099e15ba8b2bedd75ecccb5ed3d |
|
BLAKE2b-256 | e96b8fc4f1716dd35e27d05c92ad41e6e3512b0f0994475e921755d4dabf26f8 |