Skip to content

Commit

Permalink
Update README and docs for as_completed_safe()
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed May 3, 2023
1 parent a892cc1 commit 5484ebb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ Modules
* [Async Functools](http://aiotools.readthedocs.io/en/latest/aiotools.func.html)
* [Async Itertools](http://aiotools.readthedocs.io/en/latest/aiotools.iter.html)
* [Async Server](http://aiotools.readthedocs.io/en/latest/aiotools.server.html)
* [Async TaskGroup](http://aiotools.readthedocs.io/en/latest/aiotools.taskgroup.html)
* [Supervisor](http://aiotools.readthedocs.io/en/latest/aiotools.supervisor.html)
* [(Persistent)TaskGroup](http://aiotools.readthedocs.io/en/latest/aiotools.taskgroup.html)
* [Async Timer](http://aiotools.readthedocs.io/en/latest/aiotools.timer.html)
* [High-level Coroutine Utilities](http://aiotools.readthedocs.io/en/latest/aiotools.utils.html)

I also recommend to try the following asyncio libraries for your happier life.

* [async_timeout](https://github.com/aio-libs/async-timeout): Provides a light-weight timeout wrapper that does not spawn subtasks.
* [aiojobs](https://github.com/aio-libs/aiojobs): Provides a concurrency-limited scheduler for asyncio tasks with graceful shutdown.
* [trio](https://github.com/python-trio/trio): An alternative implementation of asynchronous IO stack for Python, with focus on cancellation scopes and task groups called "nursery".

Expand Down
9 changes: 7 additions & 2 deletions src/aiotools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ async def as_completed_safe(
) -> AsyncGenerator[Awaitable[T], None]:
"""
This is a safer version of :func:`asyncio.as_completed()` which uses
:class:`Supervisor` as an underlying coroutine lifecycle keeper.
:class:`aiotools.Supervisor` as an underlying coroutine lifecycle keeper.
This requires Python 3.11 or higher to work properly with timeouts.
.. versionadded:: 1.6
.. versionchanged:: 2.0
It now uses :class:`aiotools.Supervisor` internally and handles
timeouts in a bettery way.
"""
q: asyncio.Queue[asyncio.Task[Any]] = asyncio.Queue()
remaining = 0
Expand Down Expand Up @@ -112,7 +117,7 @@ async def race(
If ``continue_on_error`` is set True, it will keep running until it encounters
the first successful result. Then it returns the exceptions as a list in the
second item of the returned tuple. If all coroutines fail, it will raise an
exc:`ExceptionGroup` to indicate the explicit failure of the entire operation.
:exc:`ExceptionGroup` to indicate the explicit failure of the entire operation.
.. versionadded:: 2.0
"""
Expand Down

0 comments on commit 5484ebb

Please sign in to comment.