This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lanfon72
Recipients asvetlov, lanfon72, yselivanov
Date 2021-03-06.14:09:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615039793.26.0.615166791283.issue43419@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-03-06 14:09:53lanfon72setrecipients: + lanfon72, asvetlov, yselivanov
2021-03-06 14:09:53lanfon72setmessageid: <1615039793.26.0.615166791283.issue43419@roundup.psfhosted.org>
2021-03-06 14:09:53lanfon72linkissue43419 messages
2021-03-06 14:09:51lanfon72create