Subprocess .wait() is not waiting

adam.c.bernier adam.c.bernier at kp.org
Fri Mar 24 15:59:28 EDT 2017


On Friday, March 24, 2017 at 12:41:22 PM UTC-7, Ian wrote:
> On Fri, Mar 24, 2017 at 12:42 PM, adam.c.bernier <adam.c.bernier at kp.org> wrote:
> > Hi,
> >
> > I am on Windows 7. Python 2.7
> >
> > I'm trying to have a program run another program using `subprocess.Popen`
> >
> >     import subprocess as sp
> >
> >     args = shlex.split(args)
> >     proc = sp.Popen(args,stdout=sp.PIPE,stderr=sp.PIPE)
> >     out, err = proc.communicate()
> >     proc.wait()
> >
> > But it *sometimes* doesn't wait and the other program -- which generates a set of 14 Excel files -- does not complete before control is returned to the calling program.
> >
> > Any ideas on what I can do to make `subprocess.wait()` actually wait?
> >
> > Thanks in advance for any assistance you might be able to provide.
> 
> If that's what's happening it would be a bug. Are you sure that the
> other program isn't simply crashing or otherwise failing to complete?
> 
> By the way, the wait in the code above is redundant because
> communicate already waits.

Thank you for the comment about the wait being redundant. Much appreciated.


More information about the Python-list mailing list