Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-77714: Provide an async iterator version of as_completed#22491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
serhiy-storchaka merged 20 commits intopython:mainfromJustinTArthur:async-for-as-completed
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
5b14951
bpo-33533: Provide an async iterator version of as_completed
JustinTArthurOct 1, 2020
f0f22f0
New docstring for revised async iteration pattern. Doc polish.
JustinTArthurOct 4, 2020
27d546a
Remove internal callbacks on as_completed iterator deletion.
JustinTArthurOct 4, 2020
c049b3a
Update docstring of concurrent test for revised async iterator shape
JustinTArthurOct 4, 2020
8912149
Clarify TimeoutError source in as_completed docstring.
JustinTArthurOct 4, 2020
ffde36a
Merge branch 'master' into async-for-as-completed
JustinTArthurNov 6, 2020
397c3b3
Merge branch 'main' into async-for-as-completed
serhiy-storchakaDec 19, 2023
f759fb4
Fix tests.
serhiy-storchakaDec 20, 2023
c74a169
Update docs.
serhiy-storchakaDec 20, 2023
a2b3b77
Avoid circular import problem.
serhiy-storchakaDec 21, 2023
0915257
Small refactoring.
serhiy-storchakaDec 21, 2023
9e6658a
Remove __del__ method which does not have effect.
serhiy-storchakaDec 21, 2023
32ac402
Fix What's New/
serhiy-storchakaDec 21, 2023
a6cdcf7
Doc and docstring changes following @gvanrossum review.
JustinTArthurFeb 10, 2024
40c13ad
Consistent quotation marks in examples.
JustinTArthurFeb 27, 2024
0e56f0b
Apply suggestions from code review.
JustinTArthurFeb 28, 2024
c4d84ab
Expand as_completed examples, clean _AsCompleted docstring salad.
JustinTArthurFeb 29, 2024
8863a55
Merge branch 'main' into async-for-as-completed
JustinTArthurFeb 29, 2024
378b69c
Import queues module at module-level of asyncio.tasks.
JustinTArthurMar 1, 2024
0ba0b29
Merge branch 'main' into async-for-as-completed
JustinTArthurApr 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Clarify TimeoutError source in as_completed docstring.
  • Loading branch information
@JustinTArthur
JustinTArthur committedOct 4, 2020
commit891214931c1be17a37cd5a684b3f6b1fe16dfef3
3 changes: 2 additions & 1 deletionDoc/library/asyncio-task.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -609,7 +609,8 @@ Waiting Primitives

For backwards compatibility, the object returned by ``as_completed()``
can be iterated as a plain iterator, yielding new coroutines that return
the results of the passed in awaitables as their tasks finish.::
the results or raise the errors of the passed in awaitables as their tasks
finish.::

for aw in as_completed(aws):
earliest_result = await aw
Expand Down
10 changes: 5 additions & 5 deletionsLib/asyncio/tasks.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -640,20 +640,20 @@ def as_completed(fs, *, loop=None, timeout=None):
Coroutines will be scheduled and their implicitly created tasks will be
yielded instead.

Any exception from the given awaitables will be raised by the async for
statement, as will a TimeoutError if the timeout is reached before
the iterator is exhausted.
A TimeoutError is raised by the async for statement if the supplied
timeout is reached before the iterator is exhausted.

For backwards compatibility, the returned object can also be used as a
plain iterator that yields new coroutines representing each next awaitable
to be completed:

for next_completed in as_completed(fs):
result = await next_completed # The 'await' may raise.
result = await next_completed
# Use result.

The coroutines yielded by the plain iterator are not the original
awaitables passed in.
awaitables passed in and are the source of TimeoutErrors instead of the
for loop.
"""
if inspect.isawaitable(fs):
raise TypeError(
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp