gh-124594: Create and reuse one context for the entire asyncio REPL session#124595
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
b68b941 to
ea27b64
Compare
Misc/NEWS.d/next/Library/2024-09-26-13-43-39.gh-issue-124594.peYhsP.rst
Outdated
Show resolved
Hide resolved
|
This needs a NEWS entry, per the bot, as this is a user-facing bug. (Also, hi!) |
|
Is this specific to a new REPL, or is it also a problem with the old REPL? If so, there's no need to backport it to 3.12. |
Oh, I didn't check. Does the asyncio REPL use the new REPL? |
Nevermind, I was being dumb, there's already a news entry. Ignore that! |
Yes, it is. |
c475f7b to
a626ea8
Compare
|
Another fun fact I've also observed is that
Details(This failure is a demo of a secondary concern and is effectively worked around in this PR.) |
ZeroIntensity
left a comment
There was a problem hiding this comment.
I manually confirmed locally that this fixes the problem. FWIW, @Eclips4, I checked that this does apply to 3.12, so we're fine with the backport.
I haven't followed the new repl change so can't review but |
|
As far as I can see, this isn't specific to the new REPL. |
|
LGTM, thanks! |
…ncio REPL session (pythonGH-124595) (cherry picked from commit 67e01a4) Co-authored-by: Bartosz Sławecki <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]>
…ncio REPL session (pythonGH-124595) (cherry picked from commit 67e01a4) Co-authored-by: Bartosz Sławecki <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]>
|
GH-124848 is a backport of this pull request to the 3.13 branch. |
|
GH-124849 is a backport of this pull request to the 3.12 branch. |
…yncio REPL session (GH-124595) (#124848) gh-124594: Create and reuse the same context for the entire asyncio REPL session (GH-124595) (cherry picked from commit 67e01a4) Co-authored-by: Bartosz Sławecki <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]>
…yncio REPL session (GH-124595) (#124849) * gh-124594: Create and reuse the same context for the entire asyncio REPL session (GH-124595) (cherry picked from commit 67e01a4) Co-authored-by: Bartosz Sławecki <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]> --------- Co-authored-by: Bartosz Sławecki <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]>
Fixes gh-124594.
Closes gh-87585.
I was initially slightly unsure how to test it, and
spawn_repl("-m", "asyncio")is proven to be quirky (launch./python -I -i -m asyncioby yourself and then type inexitand see what happens)—please let me know if there's a better way.I used
copy_context()to assign the copied context to theAsyncIOInteractiveConsole.contextattribute, and didn't make acontextparameter as I didn't see that necessary (it doesn't really seem to be a part of the public API, even though it can be imported and used by anyone, and it's also not in the typeshed).I believe
copy_context()makes more sense than manually constructing the context withContext()because thepythonstartup.pyscript can set some context variables, but I'm open to discussion about that.