I have a Python 3 question. How do I automatically get the returncode from a Popen object after the child process terminates?
In short, I need an application to wait, but not be unresponsive (if possible), until the child process ends, and then automatically call a function based on the returncode.
The following "might" be what you're looking for, but it's possible I don't quite understand what you want.
import subprocess
child = subprocess.Popen(do_something_here)
streamdata = child.communicate()[0]
rc = child.returncode
You can find more information about this here:
http://docs.python.org/2/library/subprocess.html#subprocess.Popen.returncode
If I misunderstood your question, please let me know and I'll try and help you more with this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.