-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
bpo-43419: fix contextvars behaviors in asyncio REPL #24773
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
I think there still got a bug that REPLThread use here is the expected behavior using aioconsole: Python 3.8.6 (default, Oct 18 2020, 00:27:24)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
---
This console is running in an asyncio event loop.
It allows you to wait for coroutines using the '{0}' syntax.
Try: await asyncio.sleep(1, result=3)
---
>>> from contextvars import ContextVar
>>> ctx = ContextVar('ctx')
>>> ctx.set(1)
<Token var=<ContextVar name='ctx' at 0x10b077db0> at 0x10b0c1cc0>
>>> ctx.get()
1
>>> async def awtf():
... ctx.set(2)
... return ctx.get()
...
>>> await awtf()
2
>>> ctx.get()
2
>>> |
This PR is stale because it has been open for 30 days with no activity. |
@ZeroIntensity I think you can close this one too. |
bug tracker
I just make the little enhance to propagate
Context
between MainThread and REPLThread, to let contextvars work properly in asyncio REPL environment.Here is the new behavior after this PR merged:
https://bugs.python.org/issue43419