Asynchronous 如何刷新pygtk/gnome';s gobject.spawn\u异步

Asynchronous 如何刷新pygtk/gnome';s gobject.spawn\u异步,asynchronous,pygtk,gobject,Asynchronous,Pygtk,Gobject,我使用以下调用生成一个进程,获取其stdin、stdout和stderr的文件描述符,并监视其stdout上的输出: [widget.pid,widget.stdin,widget.stdout,widget.stderr] = \ gobject.spawn_async(['/bin/sed','s/hi/by/g'], standard_input=True,

我使用以下调用生成一个进程,获取其stdin、stdout和stderr的文件描述符,并监视其stdout上的输出:

[widget.pid,widget.stdin,widget.stdout,widget.stderr] = \
            gobject.spawn_async(['/bin/sed','s/hi/by/g'], 
                                standard_input=True,
                                standard_output=True,
                                standard_error=True
                                )
 gobject.io_add_watch(widget.stdout,
                      gobject.IO_IN,
                      getdata)
然后我将行写入widget.stdin,期望触发回调函数getdata

我发现只有在关闭widget.stdin时才会调用回调getdata

另一方面,从终端上看,sed会回显发送到stdin的每条已完成的行,因此我认为sed在stdin上看到已完成的行时会生成输出,而不是一次只获取一行


我不清楚如何强制写入widget.stdin的行显示在/bin/sed,同时保持连接打开以发送更多行。python-u标志似乎没有任何区别。有什么想法吗?谢谢。

我想我可能问错了问题;我将以不同的标题提交此文件

我发现,只有当孩子的管道充满时,孩子标准输出上的手表才会在家长中触发;换句话说,在管道填充之前,子进程(“sed”进程)似乎不会实际接收任何输入。当我将管道大小设置为4096并用4096字节将管道预填充到子级时,我可以发送512字节的块,并且每次我向子级发送新块时,都会调用我的父进程“io_add_watch callback”,它将读取512字节