Thanks, Yury, for the quick reply, but I just realized my question was based on my own mistake.

Asyncio already does exactly what I want, but I have a subprocess that wasn't inheriting PYTHONASYNCIODEBUG=1 from its parent. Once I've exported this environment variable to the subprocess, I am now seeing stack traces that show where pending tasks were created.

Sorry everybody! Please ignore this thread...

On Thu, Feb 2, 2017 at 2:53 PM, Yury Selivanov <yselivanov@gmail.com> wrote:

> On Feb 2, 2017, at 2:40 PM, Mark E. Haase <mehaase@gmail.com> wrote:
>
> Is it possible to see where this task was created, e.g. the line containing asyncio.ensure_future(asyncio.sleep(...)) ? If not, is this a capability that could be added to debug mode? E.g. ensure_future would add its own stack trace to the task object so that it could be retrieved later when a pending task is destroyed.
>

Yeah, this is doable. I suggest you to open an issue on bugs.python.org.

Yury