Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-97696: asyncio eager tasks factory#102853
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
38 commits Select commitHold shift + click to select a range
a127f98 Eager task factory implementation
itamaro45316d8 Eager task factory tests
itamaroac9b7b0 Add NEWS and docs for eager task factory
itamaro402c317 elaborate explanation in docs and add a whatsnew entry
itamaro563ffd4 fix docs
itamaro6f2a47a Overhaul eager task factory design
itamaroe7743f6 Fix task-counting tests for new impl
itamaro10a03a0 Fix test_task_exc_handler_correct_context
itamaro5e8ae51 Merge branch 'main' into eager-tasks-factory
itamarob4fea1c Merge branch 'main' into eager-tasks-factory
itamaro441fd92 add jbower credit
itamaro4c46a72 cleanup recursive_taskgroups test case
itamaro8686a3d Merge branch 'main' into eager-tasks-factory
itamaro14b6f58 Update asyncio documentation with latest state of the PR
itamaro0f9185c don't add coro to the task repr if coro is None
itamaro679534a also update the NEWS entry
itamaro70bb3d4 add error check when using _PyDict_GetItem_KnownHash in swap_current_…
itamaro7edcf3f focus the eager task factory test suite on testing eager execution se…
itamaro45e5c8c ensure task_eager_start is not called with a NULL task
itamarofbf8d91 Refactor eager task tests to clarify the "loop is running" constraint…
itamaro873a645 Apply documentation suggestions and feedback
itamaro9c2bc9a Merge remote-tracking branch 'upstream/main' into eager-tasks-factory
itamaro9522c54 fix docs (rst is hard)
itamaro2acdc51 Merge branch 'main' into eager-tasks-factory
itamarofef8140 Extend eager task factory tests
jbower-fb1eb540c a little cleanup of newly added tests
itamaro3cef856 add assertion to current_task test, comparing the task before and aft…
itamaro8877716 add a second step to contextvars test
itamaro57ccce3 Merge branch 'main' into eager-tasks-factory
itamaro57b197f Merge branch 'main' into eager-tasks-factory
willingcc545645 Merge branch 'main' into eager-tasks-factory
itamaro0c09767 missing word in NEWS entry
itamaroa255ec8 refactor all_tasks() handling of eager_tasks
itamaro05870d5 fix docs (PR review)
itamaroa2587a1 move cv.set inside the main task (otherwise it refleaks)
itamaro0101742 Merge branch 'main' into eager-tasks-factory
itamarob83ed94 fix grammar in all_tasks comments
itamarob17f605 Merge branch 'main' into eager-tasks-factory
itamaroFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Add NEWS and docs for eager task factory
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitac9b7b035bd752cf71fc9075d6694d10c4628253
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -527,6 +527,30 @@ Running Tasks Concurrently | ||
| and there is no running event loop. | ||
| Eager Task Factory | ||
| ================== | ||
| .. function:: eager_task_factory(loop, coro, *, name=None, context=None) | ||
| A task factory for eager task execution. | ||
| When using this factory (via ``loop.set_task_factory(asyncio.eager_task_factory)``), | ||
| coroutines that are able to complete synchronously (without suspending) | ||
| are returned immediately as a completed :class:`Future`. | ||
| A regular :class:`Task` is returned otherwise, at the first suspension of *coro*. | ||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. versionadded:: 3.12 | ||
| .. function:: create_eager_task_factory(custom_task_constructor) | ||
| Create an eager task factory, similar to :func:`eager_task_factory`, | ||
| using the provided *custom_task_constructor* when creating a new task instead | ||
| of the default :class:`Task`. | ||
| .. versionadded:: 3.12 | ||
| Shielding From Cancellation | ||
| =========================== | ||
4 changes: 4 additions & 0 deletionsMisc/NEWS.d/next/Library/2023-03-15-12-18-07.gh-issue-97696.DtnpIC.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Implemented an eager task factory in asyncio. When set as a task factory on | ||
| an event loop, it performs eager execution of coroutines and returns a | ||
| completed future instead of scheduling a task to the event loop if the | ||
| coroutine can complete without suspending. |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.