[Python-Dev] PEP 567 (contextvars) idea: really implement the current context
Guido van Rossum
guido at python.org
Thu Jan 4 20:50:27 EST 2018
On Wed, Jan 3, 2018 at 6:45 PM, Victor Stinner <victor.stinner at 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180104/c0327794/attachment.html>
More information about the Python-Dev
mailing list