https://github.com/vd2org/periodic
Python asyncio periodic tasks.
https://github.com/vd2org/periodic
asyncio python
Last synced: 3 months ago
JSON representation
Python asyncio periodic tasks.
- Host: GitHub
- URL: https://github.com/vd2org/periodic
- Owner: vd2org
- License: mit
- Created: 2019-01-11T22:32:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-12T12:46:11.000Z (over 5 years ago)
- Last Synced: 2025-10-25T16:52:06.274Z (8 months ago)
- Topics: asyncio, python
- Language: Python
- Size: 17.6 KB
- Stars: 18
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# periodic
Simple tool for run asyncio tasks periodically.
# Setup
```bash
pip install asyncio-periodic
```
# Example usage
```python
import asyncio
from datetime import datetime
from periodic import Periodic
async def periodically(param):
print(datetime.now(), 'Yay!', param)
await asyncio.sleep(1)
print(datetime.now(), 'Done!')
async def main():
p = Periodic(3, periodically, 'Periodically!')
await p.start()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
```
# Testing
Code tested automatically using travis. You can see build status **[here](https://travis-ci.com/vd2org/periodic)**.
To test code manually install and run pytest:
```bash
pip install pytest
python -m pytest tests/
```