New GitHub issue #95920 from graingert:<br>
<hr>
<pre>
```
import asyncio
import threading
import concurrent.futures
async def main():
f = concurrent.futures.Future()
def timer_called():
print("timer called")
f.set_result(None)
t = threading.Timer(1, timer_called)
t.start()
await asyncio.wait({f})
asyncio.run(main())
```
on python3.10
```
Traceback (most recent call last):
File "/home/graingert/projects/cpython/bad_future.py", line 16, in <module>
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/graingert/projects/cpython/bad_future.py", line 14, in main
await asyncio.wait({f})
File "/usr/lib/python3.10/asyncio/tasks.py", line 382, in wait
fs = {ensure_future(f, loop=loop) for f in fs}
File "/usr/lib/python3.10/asyncio/tasks.py", line 382, in <setcomp>
fs = {ensure_future(f, loop=loop) for f in fs}
File "/usr/lib/python3.10/asyncio/tasks.py", line 615, in ensure_future
return _ensure_future(coro_or_future, loop=loop)
File "/usr/lib/python3.10/asyncio/tasks.py", line 630, in _ensure_future
raise TypeError('An asyncio.Future, a coroutine or an awaitable '
TypeError: An asyncio.Future, a coroutine or an awaitable is required
timer called
```
python3.11 does this (I hit ctrl+c after it prints timer called)
```
timer called
^CTraceback (most recent call last):
File "/usr/lib/python3.11/asyncio/tasks.py", line 534, in _wait
await waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/graingert/projects/cpython/bad_future.py", line 16, in <module>
asyncio.run(main())
File "/usr/lib/python3.11/asyncio/runners.py", line 187, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 120, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/graingert/projects/cpython/bad_future.py", line 14, in main
await asyncio.wait({f})
File "/usr/lib/python3.11/asyncio/tasks.py", line 427, in wait
return await _wait(fs, timeout, return_when, loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 539, in _wait
f.remove_done_callback(_on_completion)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Future' object has no attribute 'remove_done_callback'. Did you mean: 'add_done_callback'?
```
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/95920">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: graingert</p>