Object-like async scheduler
Project description
Async scheduler object
Object-like async scheduler
Install
https://pypi.org/project/async-scheduler-object/
Usage
import asyncio
from datetime import timedelta
from async_scheduler_object import AsyncScheduler, PeriodicEvent
class AgePeriodicEvent(PeriodicEvent):
def __init__(self, start: int) -> None:
self._age = start
async def run(self) -> None:
print("Age", self._age)
self._age += 1
class CatsPeriodicEvent(PeriodicEvent):
def __init__(self, start: int) -> None:
self._cats_count = start
async def run(self) -> None:
print("Cats", self._cats_count)
self._cats_count *= 1
async def main() -> None:
scheduler_1 = AsyncScheduler(
events=[AgePeriodicEvent(start=1)],
interval=timedelta(seconds=1),
)
scheduler_2 = AsyncScheduler(
events=[AgePeriodicEvent(start=10), CatsPeriodicEvent(start=20)],
interval=timedelta(seconds=0.5),
)
await scheduler_1.start()
await scheduler_2.start()
await asyncio.sleep(10)
await scheduler_1.stop()
await scheduler_2.stop()
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
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 async_scheduler_object-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89a4d9ecccc3edbb648d460097ae614321bfd774fd94a9c1bcd09d5e5e865b57 |
|
MD5 | 2f448363b7052fce38938595a10e36b4 |
|
BLAKE2b-256 | 703fbd7a3a2d2bd7e26bff5fc18116f8501e6a15b565cb1bb040b8ec1cb842b5 |
Close
Hashes for async_scheduler_object-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d6aef45559c16e73de41a498a4db75c1d49f4f847ad77fb5363327f481b384c |
|
MD5 | 9a48afaee9a22c35f600340a528153db |
|
BLAKE2b-256 | 4b20558ba8726f8a5d06879662825a8e1c9b062305e38b4103405a4b5a3d0cb2 |