On 28 fév, 10:13, [EMAIL PROTECTED] wrote:
> On 27 fév, 19:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 27 Feb 2007 05:39:51 -0800, [EMAIL PROTECTED] declaimed the
> > following in comp.lang.python:
>
> > > On 27 fév, 12:27, Thinker <[EMAIL PROTECTED]> wrote:
> > > > -----BEGIN PGP SIGNED MESSAGE-----
> > <snip>
>
> > > > Your program will be blocked here until child process being terminated.
> > > > You should print your messages before this line.
>
> > > i have tried as you said (cf bellow) and same result...
>
> > No, you did NOT do as was suggested (unless you misunderstood which
> > line "before this" meant.
>
> > > is there any link which explain how a server Web read script and send
> > > the answer ?
>
> > > -------------------------------------------------------------------------
> > > pid = os.spawnl(os.P_NOWAIT,"c:\\python25\
> > > \python.exe","python","Main.py")
> > > ret = os.waitpid(pid,0)
>
> > As soon as you execute os.waitpid(), your script WAITS. NOTHING
> > after that point will happen until the process you are waiting on exits.
>
> > > print """please wait ...."""
> > > sys.stdout.flush()
> > > # retourne le process id
> > > if ( ret[1] != 0):
> > > print """ wait %i """ %ret[1]
> > > sys.stdout.flush()
> > > else:
> > > print """ end %i """ %ret[1]
> > > sys.stdout.flush()
>
> > pid = os.spawnl(os.P_NOWAIT,
> > "c:\\python25\\python.exe",
> > "python",
> > "Main.py") #apparently a Windows
> > OS
> > print "Please wait ..."
> > sys.stdout.flush()
> > ret = os.waitpid(pid, 0)
>
> > if ret[1]:
> > print "Non-zero exit code: %s %s" % (ret[1], ret[0])
> > else:
> > print "Successful exit"
> > sys.stdout.flush()
>
> > {I'm presuming a 0 return code means success... VMS used 1 for success
> > and 0 for failure [actually, odd numbers were informational status, even
> > numbers were error status]}
>
> > > ---------------------------------------------------------------------------
> > > thanks
>
> > --
> > Wulfraed Dennis Lee Bieber KD6MOG
> > [EMAIL PROTECTED] [EMAIL PROTECTED]
> > HTTP://wlfraed.home.netcom.com/
> > (Bestiaria Support Staff: [EMAIL PROTECTED])
> > HTTP://www.bestiaria.com/
>
> hello
>
> thanks a lot..
>
> sorry for misunderstanding, my english isn't good (i'm french).
>
> i have tried like this:
> ----------------------------------------------
> #! C:/Python25/python.exe
> # -*- coding: cp1252 -*-
>
> import cgitb; cgitb.enable()
> import os,sys
>
> print "Content-Type: text/html"
> print
>
> pid = os.spawnl(os.P_NOWAIT,"c:\\python25\
> \python.exe","python","Main.py")
> print "please wait.."
> sys.stdout.flush()
> ret = os.waitpid(pid,0)
> # retourne le process id
> if ret[1]:
> print "Non-zero exit code: %s %s" % (ret[1], ret[0])
> else:
> print "Successful exit"
> sys.stdout.flush()
> --------------------------------------------------------
>
> and the result:
>
> At the end of the script execution it write:
> ==>>>> please wait.. Successful exit
>
> The browser doesn't let the script executing on background to write
> the message at once.. it waits the end.
>
> what happend?- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
re hello
perhaps there is a link with the script being called..
as there is a function which use stdout:
here it is
--------------------------------------------
def erreur_ccm(cmd):
try:
child_stdin, child_stdout, child_stderr =os.popen3(cmd)
stderr=child_stderr.read()
stdout=child_stdout.read()
if stderr == "":
retour = stdout
else :
retour = 0
except OSError, e:
child_stdin.close()
child_stdout.close()
child_stderr.close()
return retour
----------------------------------------------
--
http://mail.python.org/mailman/listinfo/python-list