On Thu, Dec 28, 2017 at 5:28 AM, Chris Jerdonek <chris.jerdo...@gmail.com> wrote: > I have a couple basic questions around how this API could be used in > practice. Both of my questions are for the Python API as applied to Tasks in > asyncio. > > 1) Would this API support looking up the value of a context variable for > **another** Task? For example, if you're managing multiple tasks using > asyncio.wait() and there is an exception in some task, you might want to > examine and report the value of a context variable for that task.
No, unless that another Task explicitly shares the value or captures its context and shares it. Same as with threading.local. > > 2) Would an appropriate use of this API be to assign a unique task id to > each task? Or can that be handled more simply? I'm wondering because I > recently thought this would be useful, and it doesn't seem like asyncio > means for one to subclass Task (though I could be wrong). The API should be used to share one ID between a Task and tasks it creates. You can use it to store individual Task IDs, but a combination of a WeakKeyDictionary and Task.current_task() seems to be a better/easier option. Yury _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com