#158192·Python

asyncio: expose the Future in FutureIter for introspection?

Author: msullivanCreated Sep 25, 2026Updated Sep 28, 2026
Labelstype-featuretopic-asyncioextension-modules

Feature or enhancement

Proposal:

I am aiming to do some introspection in order to find the Future that an async generator is blocked on.

If it is blocked on a _PyFuture, chasing down the chain of cr_awaits and ag_awaits eventually gets to a generator for Future.__await__, from which self could be extracted from the frame.

But more realistically, it is blocked on a C future, and the chain leads to a FutureIter object. The FutureIter has a future member, but it isn't exposed.

It would be pretty easy to expose it; could we? As fi_future, maybe? No strong opinion on the name.

The most annoying question is what to do about the _PyFuture version: should it stay as it is, and introspection would have to look at the frame, or should it match the C version and expose it as an attribute?

The implementation of this is super straightforward; I can put up a PR if we think we want to do this.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response