Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alttch/aiosched
Python asyncio jobs scheduler
https://github.com/alttch/aiosched
asyncio interval jobs python python3 scheduler tasks
Last synced: about 2 months ago
JSON representation
Python asyncio jobs scheduler
- Host: GitHub
- URL: https://github.com/alttch/aiosched
- Owner: alttch
- License: mit
- Created: 2019-12-06T21:29:37.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-16T23:56:52.000Z (almost 5 years ago)
- Last Synced: 2024-10-07T22:35:41.794Z (3 months ago)
- Topics: asyncio, interval, jobs, python, python3, scheduler, tasks
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aiosched - Python asyncio jobs scheduler
Executes specified asyncio jobs with a chosen interval. Has relatively small
number of features but it's fast.
## Why one more scheduler?
* it's extremely accurate and fast
* it's simple
* all methods are thread-safe## Example
```python
from aiosched import scheduler
import asyncioasync def test1(a, b, c):
print(f'JOB1 {a} {b} {c}')async def test2():
print('JOB2')async def test3():
print('JOB3')loop = asyncio.new_event_loop()
scheduler.start(loop=loop)
# jobs can be added before actual start in pending mode
job1 = scheduler.create_threadsafe(target=test1, args=(1, 2, 3), interval=1)
job2 = scheduler.create_threadsafe(target=test2, interval=0.5)
# run job once after 5 seconds
job3 = scheduler.create_threadsafe(target=test3, number=1, timer=5)
# cancel job 2
scheduler.cancel(job2)
# equal to
job2.cancel()loop.run_forever()
```or run scheduler loop as coroutine:
```python
loop = asyncio.new_event_loop()
job1 = scheduler.create_threadsafe(target=test1, args=(1,2,3), interval=0.1)
job2 = scheduler.create_threadsafe(target=test2, interval=0.1)
loop.run_until_complete(scheduler.scheduler_loop())
```## Install
```shell
pip3 install aiosched
```## Advanced
Read **AsyncJobScheduler** and **AsyncScheduledJob** classes documentation in
pydoc.