Skip to content

Commit 2199412

Browse files
authored
asyncio.ensure_future
1 parent 66a3b87 commit 2199412

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/test_async.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ async def main():
1515
task = asyncio.create_task(my_func())
1616
res = await asyncio.gather(task)
1717

18+
async def main_legacy():
19+
future = asyncio.ensure_future(my_func())
20+
res = await asyncio.gather(future)
21+
1822
if __name__ == '__main__':
1923
if sys.version_info >= (3, 7):
2024
asyncio.run(main()) # main loop
2125
else:
2226
loop = asyncio.get_event_loop()
23-
loop.run_until_complete(main())
27+
loop.run_until_complete(main_legacy())

0 commit comments

Comments
 (0)