How to create and use multiple pipes within the same process with pexpect?

点点圈 提交于 2019-12-22 14:46:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!