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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d27a043b4629ae84b85e4e8af285c40104e37866532ee0eb80229eb86a68bef7 |
|
MD5 | 7251a90e0514dea7f131da01a3b2156d |
|
BLAKE2b-256 | 0884aa18fe1366b9d4500bb79a430850c4cdd7e75d79b3402d2ad015c0d75ce2 |
Close
Hashes for timewheel_scheduler-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f569b7129ce371674dfa718a128cdbaf2b0338b7fe94b04927e391fe3c9b842d |
|
MD5 | 5a5f27d3da613e14af9456fabb0a1a3b |
|
BLAKE2b-256 | 0951f5d442a2b5e1b0be4cb462e189a548b304ca5e11927b039612eb7f9aed48 |