proc = subprocess.Popen(['start'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
proc.stdin.write('issue commands')
proc.stdin.write('issue more commands')
output = proc.stdout.read() # Deadlocked here
# Actually I have more commands to issue here
Run Code Online (Sandbox Code Playgroud)
我知道communic()可以给我一个解决这个问题的方法,但我想稍后发出更多的命令.但是communication()有点关闭子进程.
这有什么知道的工作吗?我正在尝试使用python包装器与路由器进行交互.所以我有更多的命令出现,也可以产生一些输出.在那种情况下,如何在不终止子进程的情况下进行读取.