Popen.subprocess
définira l'attribut returncode
quand c'est fait (*). Voici la section de documentation pertinente:
Popen.returncode
The child return code, set by poll() and wait() (and indirectly by communicate()).
A None value indicates that the process hasn't terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).
Donc, vous pouvez simplement faire (je ne l'ai pas testé mais cela devrait fonctionner):
import subprocess as sp
child = sp.Popen(openRTSP + opts.split(), stdout=sp.PIPE)
streamdata = child.communicate()[0]
rc = child.returncode
(*) Cela est dû à la façon dont il est implémenté: après avoir configuré les threads pour lire les flux de l'enfant, il appelle simplement wait
.