[Python-ideas] concurrency-local namespaces

Eric Snow ericsnowcurrently at gmail.com
Wed Apr 22 20:12:53 CEST 2015


On Wed, Apr 22, 2015 at 11:46 AM, Guido van Rossum <guido at python.org> wrote:
> Hey Nathaniel, can you bring this up in the PEP 492 thread? It sounds like
> it would be super great if the async with statement would (optionally?)
> notify the context manager of switching to a different task and back.

Interesting idea.  Keep in mind that decimal.localcontext() makes use
of thread-local namespaces.  So we may still be better off if we can
adapt that concept to coroutines.  If I've understood correctly,
Tasks.current_task() should give us what we need.  I'm just not clear
on a couple things.  Where does the loop comes from?  Can more than
one loop be running at the same time?  I probably need to go dig into
the asyncio docs.

-eric


More information about the Python-ideas mailing list