[Python-ideas] concurrency-local namespaces

Eric Snow ericsnowcurrently at gmail.com
Wed Apr 22 01:48:47 CEST 2015


threading.local provides thread-local namespaces.  As far as I can
tell, there isn't an equivalent for coroutines (asyncio), even though
I would expect they would provide the same benefits.  I'd like to see
coroutine-local namespaces added and would be happy to work on the
problem.  I plan on working on a feature that will rely on applying a
thread-local context and realized that coroutines would need a similar
treatment.  Also, there are probably a few spots in the stdlib that
would benefit (e.g. decimal contexts).

Perhaps I'm missing something.  Is the concurrency story with
coroutines different enough that coroutine-local namespaces do not
make sense?

If they still make sense, is there a mechanism to uniquely identify
the "currently running" coroutine like you can with threads?  That
would be necessary to do a naive port of thread-local namespaces.

-eric


More information about the Python-ideas mailing list