Python Run a daemon sub-process & read stdout

后端 未结 3 651
暗喜
暗喜 2020-11-29 04:52

I need to run a program and gather its output to stdout. This program (socat) needs to run in the background for the duration of the python script. Socat sits in dameon mode

3条回答
  •  臣服心动
    2020-11-29 05:34

    If you supply it with a pipe for stdout and stderr, I think the subprocess will block waiting for the pipes to be read. .read() should read to EOF, I think. Between them, those two issues prolly makes a deadlock.

    However, I think that since .read() will read till EOF, it will block even if there is no stderr pipe.

    You want to stick the reading in a thread, I think.

提交回复
热议问题