https://github.com/darkarp/asynchelper
https://github.com/darkarp/asynchelper
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/darkarp/asynchelper
- Owner: darkarp
- License: mit
- Created: 2021-04-10T11:20:52.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-10T21:31:01.000Z (about 5 years ago)
- Last Synced: 2025-06-03T14:44:42.204Z (about 1 year ago)
- Language: Python
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
asynchelper
===========
.. image:: https://img.shields.io/pypi/v/asynchelper.svg
:target: https://pypi.python.org/pypi/asynchelper
:alt: Latest PyPI version
Allows execution of unlimited number of asynchronous tasks while limiting the amount of active concurrent ones.
Usage
-----
There are only two functions (for now):
* `asynchelper.TaskExecutor.map(task_generator: Iterable[callable], workers: Union(int, None) = 128)`
* `task_generator` can be any iterable which holds (or generates) coroutines.
* `workers` is the maximum limit of active tasks concurrently. `None` for no limit.
* This will keep pushing tasks in the iterable until it's fully consumed.
* `asynchelper.TaskExecutor.forever(task: callable, args: Iterable = [], workers: Union(int, None) = 128)`
* `task` is an async funtion to create a couroutine from
* `args` is an iterable of arguments to pass to `task`
* `workers` is the maximum limit of active tasks concurrently. `None` for no limit
* This will keep pushing the `task(*args)`, running them forever with a limit of `workers` active tasks at any moment.
-------
`asynchelper` was written by `Mario Nascimento `_.