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, AsyncSchedulerEvent
class AgeSchedulerEvent(AsyncSchedulerEvent):
def __init__(self, start: int) -> None:
self._age = start
async def run(self) -> None:
print("Age", self._age)
self._age += 1
class CatsSchedulerEvent(AsyncSchedulerEvent):
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=[AgeSchedulerEvent(start=1)],
interval=timedelta(seconds=1),
)
scheduler_2 = AsyncScheduler(
events=[AgeSchedulerEvent(start=10), CatsSchedulerEvent(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.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d88b83f5e1eda3584b4f90ff448ae3a42b6647a191b50cb8c2d45f95a256d34e |
|
MD5 | c27588549063feacb96c3f5a029c2cd1 |
|
BLAKE2b-256 | f7420faad0c2cc27322e051ef400d6b3e673e53e229e36921f93c7d7eb489c00 |
Close
Hashes for async_scheduler_object-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c606281ea6b36b12a0750ffa6f3ce194ae219f7b9603144ec26c3346ca16f17 |
|
MD5 | 2522657d53a64859161962d8a7a4f7fa |
|
BLAKE2b-256 | 2df2327c43e0192d8b00da490f55b243b64cf220ce060376191f11cbe1803c80 |