[issue41733] ContextVar get value is unexpected

2020-09-08 Thread Yury Selivanov
Yury Selivanov added the comment: > my expected result is all objects should be different, because the code runs > in different context. Contexts "branch", so if you store something in the context before asyncio.run it will store it in the current thread state. And then asyncio.run will

[issue41733] ContextVar get value is unexpected

2020-09-06 Thread Jason Chen
New submission from Jason Chen : import asyncio from contextvars import * var = ContextVar('VarTest', default=None) def get_var(tag=None): obj = var.get() if obj is None: obj = object() var.set(obj) print(f'{tag=}: get_var result is {obj=}') return obj async