New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subprocess error with I/O redirection to Pipes #48442
Comments
I've created on my desktop a file flooder.py containing just the following: progress=open(r"C:\Users\v-pascha\Desktop\STDERR.txt","w")
for i in range(101):
print str(i)*20
progress.write( str(i)+"\n" )
progress.close()
################## and a file receiver.py containing just : ################
import sys, os, subprocess
#os.system("pause")
subprocess.Popen(r"python
C:\Users\v-pascha\Desktop\flooder.py",stdin=subprocess.PIPE,stdout=subprocess.PIPE)
#,stdin=subprocess.PIPE,stdout=subprocess.PIPE
#os.system("pause") ##################### And when I launch receiver.py, I get a crash with that (not explicit) Original exception was:" The crash doesn't happen if I don't redirect the stdout and stdin of the |
Probably this happens because receiever.py doesn't wait for flooder.py Does this code work for you? p = subprocess.Popen("python
flooder.py",stdin=subprocess.PIPE,stdout=subprocess.PIPE)
p.wait() |
This happens because when flooder.py terminates, its stdout will be Python\sysmodule.c(1098): _check_and_flush (FILE *stream) In this function, fflush() fails. The reason why error message is not Maybe this error message can be improved in some way, but I'm not sure. |
Thansk a lot for reviewing the problem Indeed, "p.wait()" seems to do the trick in this case. Is there any global way to avoid such pipe problems ? I mean, in any Or are we sure that there won't be errors as long as children die before |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: