There are so many threads on this subject, but I ran across a
situation on Windows that I can't figure out.
I'm trying to run this little command-line exe and when I launch like
this, it hangs:
I can run this exe manually via the command prompt and it returns
after a few seconds, but more importantly when I run it as follows it
works fine:
Unfortunately I don't know too much about the exe (well, I do know
that it spits out some stdout that I collect, but I don't know the
exe's source code.)
I can't figure out why the subprocess module is having a hard time
with this particular exe. I've tried so many different permutations
of subprocess.Pope n and they all hang on this exe. Even if try to do
the usual (pseudo code):
while(returncod e is None):
returncode = run.poll()
time.sleep(1)
blah blah blah
returncode is always None... In other words, it's hung. I can't
figure out why os.system works fine, but subprocess.Pope n thinks the
process hasn't finished.
Any ideas would be greatly appreciated. I'm all ears.
situation on Windows that I can't figure out.
I'm trying to run this little command-line exe and when I launch like
this, it hangs:
>>import subprocess
>>command = r'c:\mydir\foo. exe'
>>run = subprocess.Pope n(command, shell=True, stdout=subproce ss.PIPE, stdin=None, stderr=subproce ss.PIPE, env=os.environ, universal_newli nes=True)
>>returncode = run.wait() ## HANGS HERE ##
>>command = r'c:\mydir\foo. exe'
>>run = subprocess.Pope n(command, shell=True, stdout=subproce ss.PIPE, stdin=None, stderr=subproce ss.PIPE, env=os.environ, universal_newli nes=True)
>>returncode = run.wait() ## HANGS HERE ##
after a few seconds, but more importantly when I run it as follows it
works fine:
>>import os
>>command = r'c:\mydir\foo. exe'
>>os.system(com mand) ## WORKS FINE! ##
>>command = r'c:\mydir\foo. exe'
>>os.system(com mand) ## WORKS FINE! ##
that it spits out some stdout that I collect, but I don't know the
exe's source code.)
I can't figure out why the subprocess module is having a hard time
with this particular exe. I've tried so many different permutations
of subprocess.Pope n and they all hang on this exe. Even if try to do
the usual (pseudo code):
while(returncod e is None):
returncode = run.poll()
time.sleep(1)
blah blah blah
returncode is always None... In other words, it's hung. I can't
figure out why os.system works fine, but subprocess.Pope n thinks the
process hasn't finished.
Any ideas would be greatly appreciated. I'm all ears.
Comment