剛學(xué)PYTHON的協(xié)程,我想請教下,這兩段代碼執(zhí)行起來有什么區(qū)別呢?
tasks = [asyncio.ensure_future(task(i)) for i in range(0,300)]
loop.run_until_complete(asyncio.gather(*tasks))
tasks = [task(i) for i in range(0,300)]
loop.run_until_complete(asyncio.wait(tasks))
歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~
Just look at the documentation and you will know that these two pieces of code have the same effect. However, the return values ??of wait and gather are different. Wait can also return when the first future is complete or an error occurs.