问题
I'm trying to communicate with gdb asynchronously using pexpect. If I use the same pipe to do it, the commands sent using pexpect's sendline()
function gets mixed into each other. And if I synchronize it like this:
def send_command(str):
global p
with GDB_Engine.lock:
p.sendline(str)
p.expect_exact("(gdb)")
It'll be too slow since there'll be tons of commands coming thru. So the thing I want to do is to implement different pipes for every send_command()
block then close it when the work finishes. By this way, the text generated by sendline()
commands won't get mixed into each other and I'll also be able to execute things asynchronously.
来源:https://stackoverflow.com/questions/35461497/how-to-create-and-use-multiple-pipes-within-the-same-process-with-pexpect