从python中的其他进程捕获一个进程的标准输出内容

时间:2017-02-23 04:56:25

标签: python python-2.7 python-3.x subprocess

    with ArPyUtils.StdoutInterceptor() as out1:
       config.enabled = True
       config.loggingEnabled = True
       # wait for supplicant to restart with a new pid
       Tac.waitFor( lambda: ( os.path.exists( pidfilePath ) and
                              os.path.getctime( pidfilePath ) > pidfileCreationTime ),
                              description='connectivity-monitor to come up again with pidfile' )
       assert ( open( pidfilePath ).read() != processPid )
       output = out1.contents()
       assert ( "Starting cloudtracer probe" in output )

这里我试图从标准输出中捕获进程的内容但是我什么也没得到,即输出为空。我发现的是因为我试图捕获的内容是作为一个单独的过程运行的。如何捕捉它的内容?

连接 - 监控是我试图捕获其内容的过程。我无法控制它,我只是在检查它的存在。我怎样才能抓住它的内容?

0 个答案:

没有答案
相关问题