2

I'm trying to get the output of another process in python3

Here si my code

proc = subprocess.Popen(BIN, stdout=subprocess.PIPE)
try:
    outs = proc.communicate(timeout=10)[0]
except subprocess.TimeoutExpired:
    proc.kill()
    outs = proc.communicate()[0] 

The problem is :

BIN is an executable that never finish, so TimeoutExpired is always raised. But I'm unabled to get the output in the except block

Thank's for reading

Titouan56
  • 6,932
  • 11
  • 37
  • 61
  • what does *"unable to get the output"* mean? Is the output empty? Make sure it is not a [block buffering issue (the subprocess should flush its internal stdout buffers before we can read anything on our end)](http://stackoverflow.com/q/20503671/4279). – jfs Feb 27 '15 at 17:42
  • mean the output is empty : b'' – Titouan56 Mar 04 '15 at 09:59
  • have you checked that the subprocess flushes its stdout buffers before the timeout? – jfs Mar 04 '15 at 10:07

0 Answers0