(original) (raw)

On Wed, Jan 3, 2018 at 6:45 PM, Victor Stinner <victor.stinner@gmail.com> wrote:
Is it possible to run a generator in a context explicitly using PEP
567 Context.run() API?

Yes. You execute 'ctx = copy\_context()' once, and then wrap all .next() calls in ctx.run(). This is what the PEP proposes to do for asyncio.Task -- constructing the task calls copy\_context() \_step() is always wrapped in a run() call for that context.

(This was a good question because it teases out more of the semantics of Context.run().)

--
--Guido van Rossum (python.org/\~guido)