Skip to content

bpo-47062: Implement asyncio.Runner context manager - #31799

Merged
asvetlov merged 32 commits into
mainfrom
asyncio-runner
Mar 24, 2022
Merged

bpo-47062: Implement asyncio.Runner context manager#31799
asvetlov merged 32 commits into
mainfrom
asyncio-runner

Conversation

@asvetlov

@asvetlovasvetlov commented Mar 10, 2022

Copy link
Copy Markdown
Contributor

@asvetlovasvetlov changed the title asyncio.Runner context managerbpo-47062: asyncio.Runner context managerMar 18, 2022
@asvetlovasvetlov changed the title bpo-47062: asyncio.Runner context managerbpo-47062: Implement asyncio.Runner context managerMar 18, 2022
@asvetlov
asvetlov marked this pull request as ready for review March 18, 2022 20:46
@asvetlov
asvetlov requested a review from 1st1 as a code ownerMarch 18, 2022 20:46

@zwarezware left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few mostly grammatical suggestions, but otherwise LGTM.

There may be a few comments that no longer apply; I started reviewing before you finished pushing changes and now I can't find them to remove them :)

Comment threadDoc/library/asyncio-runner.rst Outdated
Comment threadLib/asyncio/runners.py Outdated
Comment threadDoc/library/asyncio-runner.rst Outdated
Comment threadLib/asyncio/runners.py Outdated
Comment threadLib/test/test_asyncio/test_runners.py
asvetlovand others added 5 commits March 19, 2022 00:11
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
@asvetlov

Copy link
Copy Markdown
ContributorAuthor

Thanks, @zware
Notes are fixed

Comment threadLib/asyncio/runners.py
Comment threadLib/asyncio/runners.py Outdated
Comment threadLib/asyncio/runners.py Outdated
@asvetlov

Copy link
Copy Markdown
ContributorAuthor

I've modified the Runner class to use lazy initialization: __enter__ or the first run() creates embedded loop and contextvars.Context.

@1st1 does it look better for you?

@asvetlov

Copy link
Copy Markdown
ContributorAuthor

Explicit runner.get_context() method is dropped.
An embedded context is still created at the time of embedded loop initialization.

@asvetlov
asvetlov merged commit 4119d2d into mainMar 24, 2022
@asvetlov
asvetlov deleted the asyncio-runner branch March 24, 2022 19:51
@1st1

1st1 commented Mar 24, 2022

Copy link
Copy Markdown
Member

Post merge: can you rename "factory" to "loop_factory"?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@asvetlov@1st1@zware@the-knights-who-say-ni@bedevere-bot