New submission from Lanfon <lanfo...@gmail.com>:
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. ---------- components: asyncio messages: 388199 nosy: asvetlov, lanfon72, yselivanov priority: normal severity: normal status: open title: contextvars does not work properly in asyncio REPL. type: behavior versions: Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43419> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com