我有我使用测试ASYNCIO与子过程的简单的Python程序:在命令行上运行这将产生所期望的结果的Python ASYNCIO子过程从未完成
import sys, time
for x in range(100):
print("processing (%s/100) " % x)
sys.stdout.flush()
print("enjoy")
sys.stdout.flush()
。
然而,从ASYNCIO调用时,它永远不会结束
process = yield from asyncio.create_subprocess_exec(
*["python", "program.py"],
stdout=async_subprocess.PIPE,
stderr=async_subprocess.STDOUT,
cwd=working_dir
)
# this never finishes
yield from process.communicate()
ps ax
展示了这个过程是<defunct>
,不知道这意味着什么
你写的东西不是有效的Python代码。 – Bakuriu