Closed
Description
Documentation
https://docs.python.org/3/library/asyncio-future.html#asyncio.isfuture
The link above describes:
a Future-like object with a _asyncio_future_blocking attribute.
However, it doesn't say exactly what constitutes "Future-like".
Since asyncio.Task and asyncio.Future both fit this test, I'm assuming it is the set (or a subset?) of the methods shared by both of these classes.
| method | Future | Task |
|---|---|---|
| result | ✅ | ✅ |
| set_result | ✅ | |
| set_exception | ✅ | |
| done | ✅ | ✅ |
| cancelled | ✅ | ✅ |
| add_done_callback | ✅ | ✅ |
| remove_done_callback | ✅ | ✅ |
| cancel | ✅ | ✅ |
| exception | ✅ | ✅ |
| get_loop | ✅ | |
| get_stack | ✅ | |
| get_name | ✅ | |
| set_name | ✅ | |
| get_stack | ✅ | |
| uncancel | ✅ | |
| cancelling | ✅ |
Asking because I have a custom awaitable object that was being passed to asyncio.wait() that worked in the past but broke in Python 3.11 because is is missing a add_done_callback() method.
So...
- Can we get a formal definition in the docs?
- Taking it one step farther, should there be a
typing.Protocolfor "Future-like"?
Metadata
Metadata
Assignees
Projects
Status
Done