possible bug?
Earl Eiland
eee at nmt.edu
Tue Mar 22 14:15:33 EST 2005
I'm running the following code on Windows 2000, 5.00.2195:
for x in Files:
Command_String = 'C:\Program Files\WinRK\WinRK.exe -create ' +
os.path.join(InputDirectory, os.path.splitext(x)[0]) + ' -set
compression_method ppmz -setg include_paths none -add ' +
os.path.join(InputDirectory, x) + ' -apply -quit'
PROC = subprocess.Popen(Command_String)
PROC.wait()
... # process WinRK output
This hangs occasionally, and is not repeatable - it never hangs on the
same file.
Replacing the PROC.wait() command with the loop
while PROC.poll() == None: time.sleep(1)
has not hung on approximately 7,000 calls to WinRK.
Earl
On Tue, 2005-03-22 at 09:35, Jeff Epler wrote:
> On Tue, Mar 22, 2005 at 07:16:11AM -0700, Earl Eiland wrote:
> > I've been having trouble with a program hanging when using the
> > subprocess modules "wait()" method. Replacing it with with a loop that
> > used "poll()" solved the problem.
>
> Please include an example, and more information about what platforn you're using
> This simple program worked fine for me on Linux with Python 2.4:
> #------------------------------------------------------------------------
> import subprocess, time
>
> s = subprocess.Popen(['sleep', '2'])
> while 1:
> time.sleep(.1)
> if s.poll() is not None: break
> print "polling wait done", s.returncode
>
> s = subprocess.Popen(['sleep', '2'])
> s.wait()
> print "blocking wait done", s.returncode
> #------------------------------------------------------------------------
>
> Jeff
More information about the Python-list
mailing list