Thanks! Yes I mean subprocess.Popen. I was wondering the meaning of "asynchronously" Here is some code I am reading recently: " result = Popen(cmdline,shell=True,stdout=PIPE).stdout for line in result.readlines(): if find(line,"Cross") != -1: return float(split(line)[-1][0:-1]) " The computation in the program "cmdline" takes a long time, at the end of which the results will be output to stdout.
"asynchronous" seems to mean Popen returns to the parent process immediately and the parent and child processes continue to be executed. However, if Popen returns immediately to the parent process, then there will be nothing in "result", not to mention extracting information from the output. Thus it seems to me the parent process has to wait till the child process finish. So how to understand the meaning of "asynchronous"? Thanks and regards! --- On Fri, 7/24/09, Kushal Kumaran <kushal.kumaran+pyt...@gmail.com> wrote: > From: Kushal Kumaran <kushal.kumaran+pyt...@gmail.com> > Subject: Re: Popen > To: "Tim" <timlee...@yahoo.com> > Cc: python-list@python.org > Date: Friday, July 24, 2009, 10:58 AM > On Fri, Jul 24, 2009 at 7:33 PM, > Tim<timlee...@yahoo.com> > wrote: > > > > Hi, > > I wonder if I use Popen, the parent process will wait > for the child process to finish or continue without > waiting? > > Thanks and regards! > > > > Assuming you mean subprocess.Popen, the child is executed > asynchronously. You can use the wait() method on the > Popen object if > you want the parent to wait for the child to finish. > > -- > kushal > -- http://mail.python.org/mailman/listinfo/python-list