https://github.com/orsinium-labs/asynchrony
asyncio Python framework for writing safe and fast concurrent code
https://github.com/orsinium-labs/asynchrony
async asyncio concurrency framework python python3 task
Last synced: 6 months ago
JSON representation
asyncio Python framework for writing safe and fast concurrent code
- Host: GitHub
- URL: https://github.com/orsinium-labs/asynchrony
- Owner: orsinium-labs
- License: mit
- Created: 2022-07-06T14:31:05.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-09T06:52:03.000Z (over 3 years ago)
- Last Synced: 2024-05-01T15:42:33.023Z (over 1 year ago)
- Topics: async, asyncio, concurrency, framework, python, python3, task
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 18
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# asynchrony
Python [asyncio](https://docs.python.org/3/library/asyncio.html) framework for writing safe and fast concurrent code.
Features:
+ Type annotated and type safe
+ Makes it easy to work with cancellation, errors, and scheduling.
+ Well tested and well documented.
+ Zero dependency.
+ Based on real world experience and pain.## Installation and usage
```bash
python3 -m pip install asynchrony
```A simple example of starting concurrent tasks for all URLs (maximum 100 tasks at the same time) and waiting for all of them to finish:
```python
from asynchrony import Tasksasync def download_page(url: str) -> bytes:
...urls = [...]
tasks = Tasks[bytes](timeout=10, max_concurrency=100)
tasks.map(urls, download_page)try:
pages = await tasks
except Exception:
failed = sum(t.failed for t in tasks)
print(f'{failed} tasks failed')
cancelled = sum(t.cancelled for t in tasks)
print(f'{cancelled} tasks cancelled')
else:
print(f'finished {len(tasks)} tasks')
```See [tutorial](./tutorial) for runnable usage examples.