A non-blocking read on a subprocess.PIPE in Python

后端 未结 29 2589
醉酒成梦
醉酒成梦 2020-11-21 04:49

I\'m using the subprocess module to start a subprocess and connect to its output stream (standard output). I want to be able to execute non-blocking reads on its standard ou

29条回答
  •  别那么骄傲
    2020-11-21 05:03

    Working from J.F. Sebastian's answer, and several other sources, I've put together a simple subprocess manager. It provides the request non-blocking reading, as well as running several processes in parallel. It doesn't use any OS-specific call (that I'm aware) and thus should work anywhere.

    It's available from pypi, so just pip install shelljob. Refer to the project page for examples and full docs.

提交回复
热议问题