POpen - Wait For Process To Complete

Yongjian Xu jimxu at google.com
Tue Jul 3 12:35:15 EDT 2007


That's by using the P3/P4 classes not the function. the function does not
provide wait() call, it simply does it for you by default.

Jim

On 7/3/07, Robert Rawlins - Think Blue <robert.rawlins at thinkbluemedia.co.uk>
wrote:
>
> Hello guys,
>
>
>
> Quite a simple one I'm hoping. I've got a process that I run using popen
> which writes to a file, I'm then going to read the file and parse its
> contents. However, getting the application to wait until the process is
> complete and finished writing before it reads and parses the file is
> becoming complicated.
>
>
>
> Popen is meant to have a wait() function along with a poll() function
> (according to the docs), both of which can be used to make the app wait for
> the process to finished, but for some reason I can't get them working, when
> I try this:
>
>
>
>                                 Import popen2
>
>
>
>               Process = popen2.popen4('This is my command to run from
> cmd')
>
>
>
>               Process.wait()
>
>
>
>               f = open('path/to/output/file.txt')
>
>               new = f.read()
>
>               f.close()
>
>
>
> It throws back the following error to me:
>
>
>
> push.wait()
>
> AttributeError: 'tuple' object has no attribute 'wait'
>
>
>
> Which is fair enough as popen4 returns a tuple containing the output
> streams from the cmd command, but how the hell can I have it wait so I can
> read the physical files?
>
>
>
> I'll be interested to hear your thoughts guys,
>
>
>
> Rob
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Yongjian (Jim) Xu
===========
Sysops
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070703/e376f2b2/attachment.html>


More information about the Python-list mailing list