-
-
Notifications
You must be signed in to change notification settings - Fork 32k
contextvars does not work properly in asyncio REPL. #87585
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
Comments
Demonstration (via python -m asyncio): asyncio REPL 3.9.0 (default, Oct 18 2020, 00:21:26)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> from contextvars import ContextVar
>>> ctx = ContextVar('ctx')
>>> ctx.set(1)
<Token var=<ContextVar name='ctx' at 0x1021bbc70> at 0x1021bf800>
>>> ctx.get()
Traceback (most recent call last):
File "/Users/lanfon/.pyenv/versions/3.9.0/lib/python3.9/concurrent/futures/_base.py", line 440, in result
return self.__get_result()
File "/Users/lanfon/.pyenv/versions/3.9.0/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/Users/lanfon/.pyenv/versions/3.9.0/lib/python3.9/asyncio/__main__.py", line 34, in callback
coro = func()
File "<console>", line 1, in <module>
LookupError: <ContextVar name='ctx' at 0x1021bbc70>
>>> exit() It also got problem inside the functions when the context is referenced in global scope. |
3.9 is no longer maintained and I can't reproduce this on 3.10 and 3.11:
I don't know what "other problems" you were seeing, but if you are still seeing them in 3.10+ please open reopen this or create a new issue with full details. |
I'm getting the same thing with 3.11:
Oh and I'm on ARM (M1). |
Irit, you left off |
Fixed by gh-124595 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: