def task():
rfd, wfd = os.pipe()
args = [sys.executable, '-c', code, str(rfd)]
proc = yield from asyncio.create_subprocess_exec(
*args,
pass_fds={rfd},
stdout=subprocess.PIPE)
pipe = open(wfd, 'wb', 0)
transport, _ = yield from loop.connect_write_pipe(asyncio.Protocol,
pipe)
transport.write(b'data')
stdout, stderr = yield from proc.communicate()
print("stdout = %r" % stdout.decode())
transport.close()
subprocess_attach_write_pipe.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录