spawnl and waitpid

naima.mans at gmail.com naima.mans at gmail.com
Tue Feb 27 08:39:51 EST 2007


On 27 fév, 12:27, Thinker <thin... at branda.to> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
>
>
> naima.m... at gmail.com wrote:
> > On 27 f憝, 11:28, Thinker <thin... at branda.to> wrote:
> > naima.m... at gmail.com wrote:
> >>>> hello, I run a python cgi script under Apache... and while
> >>>> the script is running i want to display a "please wait"
> >>>> message until the script finish. I have tried to do this but
> >>>> the "please wait" message appears at the script end (which is
> >>>> useless at this time! )
> > You should flush sys.stdout after you print messages, or the
> > message will keep in buffer untill buffer is full or process
> > terminated.
>
> > Hello
> > thanks for answering i have flush like this but same result .. the
> > server wait until the end...
> > pid = os.spawnl(os.P_NOWAIT,"c:\\python25\
> > \python.exe","python","Main.py") sys.stdout.flush() ret =
> > os.waitpid(pid,0)
>
> Your program will be blocked here until child process being terminated.
> You should print your messages before this line.
>
> > if ( ret[1] != 0): print """ wait %i """ %ret[1]
> > sys.stdout.flush() else: print """ end %i """ %ret[1]
> > sys.stdout.flush()
>
> - --
> Thinker Li - thin... at branda.to thinker... at gmail.comhttp://heaven.branda.to/~thinker/GinGin_CGI.py
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (FreeBSD)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iD8DBQFF5BWS1LDUVnWfY8gRAkp8AKCAcTKi/MO6sfkGBBEcMjfpH42O1wCeN14I
> 0AZ83oVacK0hKik4YC/jfCA=
> =3h7d
> -----END PGP SIGNATURE------ Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

thanks again

i have tried as you said (cf bellow) and same result...
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)
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()
---------------------------------------------------------------------------
thanks




More information about the Python-list mailing list