subprocess wait() waits forever, but os.system returns
Christian Heimes
lists at cheimes.de
Wed May 7 17:31:19 EDT 2008
grayaii schrieb:
> Awesome! That worked!
> And your comment just led me down another exploration path on why the
> following doesn't work:
> ---------------------
> while(returncode is None):
> returncode = run.poll()
> time.sleep(1)
>
> out = run.stdout.readlines()
> err = run.stderr.readlines()
> ---------------------
> Nowhere in the loop am I reading stdout or err.
> I'm only reading it after the loop has finished, and when running the
> exe, returncode is *always* None.
> Now I have to figure out a way to read it within the loop without
> blocking the read... on Windows...
the subprocess has already a canonical way:
out, err = run.communicate()
Your code may still block if the stderr buffer is full during the
stdout.readlines() call.
Christian
More information about the Python-list
mailing list