i'm using in my python script:
cmd = ["checkcode.exe", "code=1234"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, close)
result = proc.stdout.readline()
checkcode.exe return a value, or nothing, and stay alive
All works fine when checkcode.exe return a value, but when checkcode.exe don't return value, the script block at result = proc.stdout.readline()
How to resolve the problem?
You must ensure that the subprocess exits in order to prevent readline() from blocking. The readline waits until it receives a newline or end-of-file. EOF is achieved on program exit.
Alternatively, you can use non-blocking I/O as mentioned in the comment above.
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.