Message388199
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. |
|
Date |
User |
Action |
Args |
2021-03-06 14:09:53 | lanfon72 | set | recipients:
+ lanfon72, asvetlov, yselivanov |
2021-03-06 14:09:53 | lanfon72 | set | messageid: <1615039793.26.0.615166791283.issue43419@roundup.psfhosted.org> |
2021-03-06 14:09:53 | lanfon72 | link | issue43419 messages |
2021-03-06 14:09:51 | lanfon72 | create | |
|