timlee126 at yahoo.com
Fri Jul 24 12:24:44 EDT 2009
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:
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+python at gmail.com> wrote:
> From: Kushal Kumaran <kushal.kumaran+python at gmail.com>
> Subject: Re: Popen
> To: "Tim" <timlee126 at yahoo.com>
> Cc: python-list at python.org
> Date: Friday, July 24, 2009, 10:58 AM
> On Fri, Jul 24, 2009 at 7:33 PM,
> Tim<timlee126 at yahoo.com>
> > Hi,
> > I wonder if I use Popen, the parent process will wait
> for the child process to finish or continue without
> > 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.
More information about the Python-list