spawnl and waitpid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • naima.mans@gmail.com

    #1

    spawnl and waitpid

    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! )

    here my script:
    ------------------------------------------------------------------------------------------------
    def get_ret(status) :
    signal = status & 0xff
    if signal == 0:
    retcode = status >8
    else:
    retcode = 0
    return signal,retcode

    pidActuel = os.spawnl(os.P_ NOWAIT,"c:\\pyt hon25\
    \python.exe","p ython","Main.py ")

    if ( get_ret(os.wait pid(pidActuel,0 ))[1] == 0 ):
    print """ END"""
    else:
    print """ please wait... """

    -------------------------------------------------------------------------------------------------

  • naima.mans@gmail.com

    #2
    Re: spawnl and waitpid


    i forgot ...
    thanks for any help :)

    Comment

    • Thinker

      #3
      Re: spawnl and waitpid

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      naima.mans@gmai l.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.


      - --
      Thinker Li - thinker@branda. to thinker.li@gmai l.com

      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.6 (FreeBSD)
      Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

      iD8DBQFF5Afi1LD UVnWfY8gRAgaoAJ 9fccAjo00QupE7S RFqgbmOUGZMugCg jvdH
      cFoxm+jiZiIpKOf d+fHCt/M=
      =9COv
      -----END PGP SIGNATURE-----

      Comment

      • naima.mans@gmail.com

        #4
        Re: spawnl and waitpid

        On 27 fév, 11:28, Thinker <thin...@branda .towrote:
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1
        >
        naima.m...@gmai l.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.
        >
        - --
        Thinker Li - thin...@branda. to thinker...@gmai l.comhttp://heaven.branda.t o/~thinker/GinGin_CGI.py
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.6 (FreeBSD)
        Comment: Using GnuPG with Mozilla -http://enigmail.mozdev .org
        >
        iD8DBQFF5Afi1LD UVnWfY8gRAgaoAJ 9fccAjo00QupE7S RFqgbmOUGZMugCg jvdH
        cFoxm+jiZiIpKOf d+fHCt/M=
        =9COv
        -----END PGP SIGNATURE-----
        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:\\pyt hon25\
        \python.exe","p ython","Main.py ")
        sys.stdout.flus h()
        ret = os.waitpid(pid, 0)

        if ( ret[1] != 0):
        print """ wait %i """ %ret[1]
        sys.stdout.flus h()
        else:
        print """ end %i """ %ret[1]
        sys.stdout.flus h()


        Comment

        • Thinker

          #5
          Re: spawnl and waitpid

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          naima.mans@gmai l.com wrote:
          On 27 fév, 11:28, Thinker <thin...@branda .towrote:
          naima.m...@gmai l.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:\\pyt hon25\
          \python.exe","p ython","Main.py ") sys.stdout.flus h() 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.flus h() else: print """ end %i """ %ret[1]
          sys.stdout.flus h()



          - --
          Thinker Li - thinker@branda. to thinker.li@gmai l.com

          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.4.6 (FreeBSD)
          Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

          iD8DBQFF5BWS1LD UVnWfY8gRAkp8AK CAcTKi/MO6sfkGBBEcMjfp H42O1wCeN14I
          0AZ83oVacK0hKik 4YC/jfCA=
          =3h7d
          -----END PGP SIGNATURE-----

          Comment

          • naima.mans@gmail.com

            #6
            Re: spawnl and waitpid

            On 27 fév, 12:27, Thinker <thin...@branda .towrote:
            -----BEGIN PGP SIGNED MESSAGE-----
            Hash: SHA1
            >
            >
            >
            >
            >
            naima.m...@gmai l.com wrote:
            On 27 f憝, 11:28, Thinker <thin...@branda .towrote:
            naima.m...@gmai l.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:\\pyt hon25\
            \python.exe","p ython","Main.py ") sys.stdout.flus h() 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.flus h() else: print """ end %i """ %ret[1]
            sys.stdout.flus h()
            >
            - --
            Thinker Li - thin...@branda. to thinker...@gmai l.comhttp://heaven.branda.t o/~thinker/GinGin_CGI.py
            -----BEGIN PGP SIGNATURE-----
            Version: GnuPG v1.4.6 (FreeBSD)
            Comment: Using GnuPG with Mozilla -http://enigmail.mozdev .org
            >
            iD8DBQFF5BWS1LD UVnWfY8gRAkp8AK CAcTKi/MO6sfkGBBEcMjfp H42O1wCeN14I
            0AZ83oVacK0hKik 4YC/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:\\pyt hon25\
            \python.exe","p ython","Main.py ")
            ret = os.waitpid(pid, 0)
            print """please wait ...."""
            sys.stdout.flus h()
            # retourne le process id
            if ( ret[1] != 0):
            print """ wait %i """ %ret[1]
            sys.stdout.flus h()
            else:
            print """ end %i """ %ret[1]
            sys.stdout.flus h()
            ---------------------------------------------------------------------------
            thanks

            Comment

            • Thinker

              #7
              Re: spawnl and waitpid

              -----BEGIN PGP SIGNED MESSAGE-----
              Hash: SHA1

              naima.mans@gmai l.com wrote:
              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:\\pyt hon25\
              \python.exe","p ython","Main.py ")
              print 'please wait...'
              ret = os.waitpid(pid, 0)
              You have missed my idea.
              Since os.waitpid will be blocked, you should print your message before
              calling os.waitpid().


              - --
              Thinker Li - thinker@branda. to thinker.li@gmai l.com


              -----BEGIN PGP SIGNATURE-----
              Version: GnuPG v1.4.6 (FreeBSD)
              Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

              iD8DBQFF5HA61LD UVnWfY8gRAu8sAJ 4n1dogsw7RzTxH8 Ke3xnNX6gXnRQCe MOKf
              /dsGHttcJc/KGpx414I7rxw=
              =E3o7
              -----END PGP SIGNATURE-----

              Comment

              • naima.mans@gmail.com

                #8
                Re: spawnl and waitpid

                On 27 fév, 18:54, Thinker <thin...@branda .towrote:
                -----BEGIN PGP SIGNED MESSAGE-----
                Hash: SHA1
                >
                naima.m...@gmai l.com wrote:
                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:\\pyt hon25\
                \python.exe","p ython","Main.py ")
                >
                print 'please wait...'
                >
                ret = os.waitpid(pid, 0)
                >
                You have missed my idea.
                Since os.waitpid will be blocked, you should print your message before
                calling os.waitpid().
                >
                - --
                Thinker Li - thin...@branda. to thinker...@gmai l.comhttp://heaven.branda.t o/~thinker/GinGin_CGI.py
                >
                -----BEGIN PGP SIGNATURE-----
                Version: GnuPG v1.4.6 (FreeBSD)
                Comment: Using GnuPG with Mozilla -http://enigmail.mozdev .org
                >
                iD8DBQFF5HA61LD UVnWfY8gRAu8sAJ 4n1dogsw7RzTxH8 Ke3xnNX6gXnRQCe MOKf
                /dsGHttcJc/KGpx414I7rxw=
                =E3o7
                -----END PGP SIGNATURE-----
                hello

                ha ok...

                i tried this one and the browser don't write the message at once... I
                have alos tried with thread and have the same result... :(

                ----------------------------------------------
                pid = os.spawnl(os.P_ NOWAIT,"c:\\pyt hon25\
                \python.exe","p ython","Main.py ")
                print 'please wait...'
                sys.stdout.flus h()
                ret = os.waitpid(pid, 0)
                # retourne le process id
                if ( ret[1] != 0):
                print """ wait %i """ %ret[1]
                sys.stdout.flus h()
                else:
                print """ end %i """ %ret[1]
                sys.stdout.flus h()
                -----------------------------

                --------- WITH THREAD ----------------

                class AsyncLaunch(thr eading.Thread):
                def __init__(self, infile):
                threading.Threa d.__init__(self )
                self.infile = infile
                def run(self):
                os.spawnl(os.P_ NOWAIT,"c:\\pyt hon25\
                \python.exe","p ython",self.inf ile)
                print 'Fin background'

                print """please wait..."""
                sys.stdout.flus h()
                sys.stdout.clos e()
                ###### # print "<a href=\\\\Fr9033 256d\execute\%s >fichier de log </
                a>" %config.nom_log
                background = AsyncLaunch('Ma in.py')
                background.star t()
                ######
                print """The main program continues to run in foreground. wait..."""
                print """ <a href='http://fr9033256d/cgi-bin/SARAT/go.py'>clic</a>"""
                background.join () # Wait for background task to finish
                print """Main program waited until background was done."""


                -------------------
                -----------------------

                Comment

                • Thinker

                  #9
                  Re: spawnl and waitpid

                  -----BEGIN PGP SIGNED MESSAGE-----
                  Hash: SHA1

                  naima.mans@gmai l.com wrote:
                  On 27 fév, 18:54, Thinker <thin...@branda .towrote:
                  hello
                  ha ok...
                  i tried this one and the browser don't write the message at once...
                  I have alos tried with thread and have the same result... :(
                  Does child-process terminate it-self in a very short time ?
                  It can be a race condition, here.
                  You can try to sleep for a while in child-process to make sure parent
                  being executed. Parent process may not schedule to run immediately
                  after spawn. And, you can print some thing before os.spawnl() to make
                  sure that message can be delivered successfully.


                  - --
                  Thinker Li - thinker@branda. to thinker.li@gmai l.com

                  -----BEGIN PGP SIGNATURE-----
                  Version: GnuPG v1.4.6 (FreeBSD)
                  Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

                  iD8DBQFF5Hkp1LD UVnWfY8gRAtDdAK CKy8/ap5VJvZV14nhSCW YfLZdyYACffJ+Y
                  0sHMgyaQBmsOMwq/rxEvm1Q=
                  =qjTU
                  -----END PGP SIGNATURE-----

                  Comment

                  • naima.mans@gmail.com

                    #10
                    Re: spawnl and waitpid

                    On 27 fév, 19:31, Dennis Lee Bieber <wlfr...@ix.net com.comwrote:
                    On 27 Feb 2007 05:39:51 -0800, naima.m...@gmai l.com declaimed the
                    following in comp.lang.pytho n:
                    >
                    >
                    >
                    On 27 fév, 12:27, Thinker <thin...@branda .towrote:
                    -----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:\\pyt hon25\
                    \python.exe","p ython","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.flus h()
                    # retourne le process id
                    if ( ret[1] != 0):
                    print """ wait %i """ %ret[1]
                    sys.stdout.flus h()
                    else:
                    print """ end %i """ %ret[1]
                    sys.stdout.flus h()
                    >
                    pid = os.spawnl(os.P_ NOWAIT,
                    "c:\\python25\\ python.exe",
                    "python",
                    "Main.py") #apparently a Windows OS
                    print "Please wait ..."
                    sys.stdout.flus h()
                    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.flus h()
                    >
                    {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
                    wlfr...@ix.netc om.com wulfr...@bestia ria.com

                    (Bestiaria Support Staff: web-a...@bestiaria. com)
                    HTTP://www.bestiaria.com/
                    hello

                    thanks a lot..

                    sorry for misunderstandin g, 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:\\pyt hon25\
                    \python.exe","p ython","Main.py ")
                    print "please wait.."
                    sys.stdout.flus h()
                    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.flus h()
                    --------------------------------------------------------

                    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?

                    Comment

                    • naima.mans@gmail.com

                      #11
                      Re: spawnl and waitpid

                      On 28 fév, 10:13, naima.m...@gmai l.com wrote:
                      On 27 fév, 19:31, Dennis Lee Bieber <wlfr...@ix.net com.comwrote:
                      >
                      >
                      >
                      >
                      >
                      On 27 Feb 2007 05:39:51 -0800, naima.m...@gmai l.com declaimed the
                      following in comp.lang.pytho n:
                      >
                      On 27 fév, 12:27, Thinker <thin...@branda .towrote:
                      -----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:\\pyt hon25\
                      \python.exe","p ython","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.flus h()
                      # retourne le process id
                      if ( ret[1] != 0):
                      print """ wait %i """ %ret[1]
                      sys.stdout.flus h()
                      else:
                      print """ end %i """ %ret[1]
                      sys.stdout.flus h()
                      >
                      pid = os.spawnl(os.P_ NOWAIT,
                      "c:\\python25\\ python.exe",
                      "python",
                      "Main.py") #apparently a Windows OS
                      print "Please wait ..."
                      sys.stdout.flus h()
                      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.flus h()
                      >
                      {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
                      wlfr...@ix.netc om.com wulfr...@bestia ria.com

                      (Bestiaria Support Staff: web-a...@bestiaria. com)
                      HTTP://www.bestiaria.com/
                      >
                      hello
                      >
                      thanks a lot..
                      >
                      sorry for misunderstandin g, 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:\\pyt hon25\
                      \python.exe","p ython","Main.py ")
                      print "please wait.."
                      sys.stdout.flus h()
                      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.flus h()
                      --------------------------------------------------------
                      >
                      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_st derr.read()
                      stdout=child_st dout.read()
                      if stderr == "":
                      retour = stdout
                      else :
                      retour = 0
                      except OSError, e:
                      child_stdin.clo se()
                      child_stdout.cl ose()
                      child_stderr.cl ose()

                      return retour
                      ----------------------------------------------

                      Comment

                      • naima.mans@gmail.com

                        #12
                        Re: spawnl and waitpid

                        On 27 fév, 19:32, Thinker <thin...@branda .towrote:
                        -----BEGIN PGP SIGNED MESSAGE-----
                        Hash: SHA1
                        >
                        naima.m...@gmai l.com wrote:
                        On 27 f憝, 18:54, Thinker <thin...@branda .towrote:
                        hello
                        ha ok...
                        i tried this one and the browser don't write the message at once...
                        I have alos tried with thread and have the same result... :(
                        >
                        Does child-process terminate it-self in a very short time ?
                        It can be a race condition, here.
                        You can try to sleep for a while in child-process to make sure parent
                        being executed. Parent process may not schedule to run immediately
                        after spawn. And, you can print some thing before os.spawnl() to make
                        sure that message can be delivered successfully.
                        >
                        - --
                        Thinker Li - thin...@branda. to thinker...@gmai l.comhttp://heaven.branda.t o/~thinker/GinGin_CGI.py
                        -----BEGIN PGP SIGNATURE-----
                        Version: GnuPG v1.4.6 (FreeBSD)
                        Comment: Using GnuPG with Mozilla -http://enigmail.mozdev .org
                        >
                        iD8DBQFF5Hkp1LD UVnWfY8gRAtDdAK CKy8/ap5VJvZV14nhSCW YfLZdyYACffJ+Y
                        0sHMgyaQBmsOMwq/rxEvm1Q=
                        =qjTU
                        -----END PGP SIGNATURE-----
                        hello

                        oki, i have test a simple script that only wait...
                        when i tun the script without the server it write on 2 time which is
                        normal:
                        =============== =============== =============== ===
                        Content-Type: text/html
                        wait
                        The main program continues to run in foreground.
                        [[[[(((then after 5 second ))]]]]]]]
                        Fin background
                        Main program waited until background was done.
                        =============== =============== =============== =====

                        BUT when i call it under the server web it write after 5 second all
                        the message in 1 time :
                        =============== =============== =============== ======
                        wait The main program continues to run in foreground. Fin background
                        Main program waited until background was done.
                        =============== =============== =============== ======

                        -----------------------THE SCRIPT ---------------------------
                        import cgitb; cgitb.enable()
                        import os,sys
                        import threading, zipfile,time,Ma in

                        print "Content-Type: text/html"
                        print
                        print "wait"
                        sys.stdout.flus h()

                        class AsyncZip(thread ing.Thread):
                        def __init__(self, infile):
                        threading.Threa d.__init__(self )
                        self.infile = infile
                        def run(self):
                        time.sleep(5.0)
                        print 'Fin background'

                        background = AsyncZip('Main. py')
                        background.star t()
                        print 'The main program continues to run in foreground.'
                        sys.stdout.flus h()
                        background.join () # Wait for background task to finish
                        print 'Main program waited until background was done.'
                        sys.stdout.flus h()
                        ---------------------------------------------------------------

                        Comment

                        • naima.mans@gmail.com

                          #13
                          Re: spawnl and waitpid

                          On 28 fév, 11:23, naima.m...@gmai l.com wrote:
                          On 27 fév, 19:32, Thinker <thin...@branda .towrote:
                          >
                          >
                          >
                          >
                          >
                          -----BEGIN PGP SIGNED MESSAGE-----
                          Hash: SHA1
                          >
                          naima.m...@gmai l.com wrote:
                          On 27 f憝, 18:54, Thinker <thin...@branda .towrote:
                          hello
                          ha ok...
                          i tried this one and the browser don't write the message at once...
                          I have alos tried with thread and have the same result... :(
                          >
                          Does child-process terminate it-self in a very short time ?
                          It can be a race condition, here.
                          You can try to sleep for a while in child-process to make sure parent
                          being executed. Parent process may not schedule to run immediately
                          after spawn. And, you can print some thing before os.spawnl() to make
                          sure that message can be delivered successfully.
                          >
                          - --
                          Thinker Li - thin...@branda. to thinker...@gmai l.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
                          >
                          iD8DBQFF5Hkp1LD UVnWfY8gRAtDdAK CKy8/ap5VJvZV14nhSCW YfLZdyYACffJ+Y
                          0sHMgyaQBmsOMwq/rxEvm1Q=
                          =qjTU
                          -----END PGP SIGNATURE-----
                          >
                          hello
                          >
                          oki, i have test a simple script that only wait...
                          when i tun the script without the server it write on 2 time which is
                          normal:
                          =============== =============== =============== ===
                          Content-Type: text/html
                          wait
                          The main program continues to run in foreground.
                          [[[[(((then after 5 second ))]]]]]]]
                          Fin background
                          Main program waited until background was done.
                          =============== =============== =============== =====
                          >
                          BUT when i call it under the server web it write after 5 second all
                          the message in 1 time :
                          =============== =============== =============== ======
                          wait The main program continues to run in foreground. Fin background
                          Main program waited until background was done.
                          =============== =============== =============== ======
                          >
                          -----------------------THE SCRIPT ---------------------------
                          import cgitb; cgitb.enable()
                          import os,sys
                          import threading, zipfile,time,Ma in
                          >
                          print "Content-Type: text/html"
                          print
                          print "wait"
                          sys.stdout.flus h()
                          >
                          class AsyncZip(thread ing.Thread):
                              def __init__(self, infile):
                                  threading.Threa d.__init__(self )
                                  self.infile = infile
                              def run(self):
                                  time.sleep(5.0)
                                  print 'Fin background'
                          >
                          background = AsyncZip('Main. py')
                          background.star t()
                          print 'The main program continues to run in foreground.'
                          sys.stdout.flus h()
                          background.join ()    # Wait for background task to finish
                          print 'Main program waited until background was done.'
                          sys.stdout.flus h()
                          ---------------------------------------------------------------- Masquer le texte des messages précédents -
                          >
                          - Afficher le texte des messages précédents -
                          hello

                          The pb seems to be solve but no idee why as i have done lot of
                          changes :/ (may be the last flush or the "\n".. i'm gone
                          investigate..)

                          THANKSSSSSSSSSS SSSSSSS for helping :)

                          for information here the code

                          ----------------------------------------------------------

                          #! C:/Python25/python.exe -u
                          # -*- coding: cp1252 -*-
                          import cgitb; cgitb.enable()
                          import os, commands, time,Parser,con fig
                          import cgi

                          import sys,Function
                          sys.stderr = sys.stdout
                          print "Content-Type: text/html"
                          print

                          pid = os.spawnl(os.P_ NOWAIT,"c:\\pyt hon25\
                          \python.exe","p ython","Main.py ")
                          print "please wait...\n"
                          print """Le fichier de log est consultable sur \\\\fr9033256d
                          \execute\%s \n""" %config.nom_log
                          sys.stdout.flus h()
                          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.flus h()

                          Comment

                          Working...