我正在嘗試使用 asyncio.create_subprocess_exec 啟動一堆子進(jìn)程:procs = []for i in range(5): proc = await asyncio.create_subprocess_exec(...) procs.append(proc.wait()) # doesn't work with this line either: procs.append(asyncio.create_task(proc.wait()))await asyncio.wait(*procs,..)# doesn't work with await asyncio.as_completed either. asyncio.gather do work, but I'd like to add timeout limit and return back to my code as earlier as possible.例外是:TypeError: expect a list of futures, not Task against line 'await asyncio.wait(*procs,..) Python 的版本是 3.8。盡管在官方文檔中警告不要自己創(chuàng)建未來,但如果有辦法將proc轉(zhuǎn)換為 Future,我想嘗試一下。
如何解決這個問題:TypeError: expect a list of futures
婷婷同學(xué)_
2022-12-20 11:22:49