* Fix contextvars.Context propagation to first yield with native coroutines
self.running = False
self.finished = False
self.io_loop = IOLoop.current()
- if self.handle_yield(first_yielded):
+ if self.ctx_run(self.handle_yield, first_yielded):
gen = result_future = first_yielded = None # type: ignore
self.ctx_run(self.run)
# so we must make sure that we maintain that property across yield.
ctx_var.reset(token)
+ @gen_test
+ def test_propagate_to_first_yield_with_native_async_function(self):
+ x = 10
+
+ async def native_async_function():
+ self.assertEquals(ctx_var.get(), x)
+
+ ctx_var.set(x)
+ yield native_async_function()
+
if __name__ == "__main__":
unittest.main()