How do I close the stdout-pipe when killing a process started with python subprocess Popen?

后端 未结 3 1581
臣服心动
臣服心动 2021-02-06 03:18

I wonder if it is possible to shut down the communication pipe when killing a subprocess started in a different thread. If I do not call communicate() then kill() will work as e

3条回答
  •  眼角桃花
    2021-02-06 03:49

    It seems to me that the easiest way to do this and sidestep the multithreading problems would be to set a kill flag from the main thread, and check for it in the script-running thread just before the communication, killing the script when the flag is True.

提交回复
热议问题