<div dir="ltr">There was some discussion of this in <a href="https://github.com/python/asyncio/issues/165">https://github.com/python/asyncio/issues/165</a> back in the days. IIRC the conclusion was that you could roll this yourself using the Tasks.current_task() class method.<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 21, 2015 at 4:48 PM, Eric Snow <span dir="ltr"><<a href="mailto:ericsnowcurrently@gmail.com" target="_blank">ericsnowcurrently@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">threading.local provides thread-local namespaces.  As far as I can<br>
tell, there isn't an equivalent for coroutines (asyncio), even though<br>
I would expect they would provide the same benefits.  I'd like to see<br>
coroutine-local namespaces added and would be happy to work on the<br>
problem.  I plan on working on a feature that will rely on applying a<br>
thread-local context and realized that coroutines would need a similar<br>
treatment.  Also, there are probably a few spots in the stdlib that<br>
would benefit (e.g. decimal contexts).<br>
<br>
Perhaps I'm missing something.  Is the concurrency story with<br>
coroutines different enough that coroutine-local namespaces do not<br>
make sense?<br>
<br>
If they still make sense, is there a mechanism to uniquely identify<br>
the "currently running" coroutine like you can with threads?  That<br>
would be necessary to do a naive port of thread-local namespaces.<br>
<br>
-eric<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>