[英]How to automatically get returncode from Popen after terminating child process?
我有一個Python 3問題。 子進程終止后,如何自動從Popen對象獲取返回碼?
簡而言之,我需要一個應用程序等待,直到子進程結束,然后才無響應(如果可能的話),然后根據返回碼自動調用一個函數。
以下“可能”是您想要的,但可能我不太了解您想要的是什么。
import subprocess
child = subprocess.Popen(do_something_here)
streamdata = child.communicate()[0]
rc = child.returncode
您可以在此處找到有關此的更多信息:
http://docs.python.org/2/library/subprocess.html#subprocess.Popen.returncode
如果我誤解了您的問題,請讓我知道,我將盡力為您提供更多幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.