Closed davidbrochart closed 5 years ago
It can be made to work by directly running the coroutine, without ensure_future:
coro = foo()
loop.run_until_complete(coro)
I'll have to look deeper if the combination of ensure_future and run_until_complete of the same task can be made to work.
The problem is that I can't modify this code. Here it is just a minimal example to reproduce the bug.
This is now fixed in v0.9.2.
Actually I have a slightly more complex case where it still hangs:
import asyncio
async def foo():
print('foo')
await asyncio.sleep(0)
print('done')
loop = asyncio.get_event_loop()
task = asyncio.ensure_future(foo())
finished, unfinished = loop.run_until_complete(asyncio.wait([task], return_when=asyncio.ALL_COMPLETED))
The code is overhauled in a pretty major way to fix this bug and several other lingering issues.
Thank you for your bug reports, they have been added as Travis test cases.
Everything works fine for me now, thanks a lot for your support!
Say you have a file
foo.py
:And a Notebook with this cell:
Executing the cell just hangs,
foo()
is not executed.