Get cgi script to begin execution of another script...

Discussion in 'Python' started by sophie_newbie, Mar 12, 2008.

  1. I've posted something similar to this already, but now I'm more sure
    of what I'm asking.

    Basically I've a CGI script, that when executed by the user, I want to
    call another script that does a very long running task (10 hours +)
    and print a message on the screen saying that the user will be emailed
    on completion of the very long task. The script executing the very
    long task will then email the user on completion.

    So far I have something like this (leaving out the obvious)...

    CGI script:

    pid = subprocess.Popen(["python", "spawn.py"]).pid
    print "Thanks you will be emailed on completion"


    Spawn.py script:

    doVeryLongCalc()
    emailUser()


    Basically the problem with this is that the cgi script page in the
    browser keeps on acting as if its loading until the Spawn.py script is
    finished executing. Somehow apache "knows" that the spawned process is
    still running in the background. So I'm basically asking if I can
    somehow spawn a script that will be completely independent of its
    parent script? So Apache doesn't know its running and the page
    finishes loading?

    Thanks if anyone can help...
    sophie_newbie, Mar 12, 2008
    #1
    1. Advertising

  2. sophie_newbie <> wrote:
    >Basically I've a CGI script, that when executed by the user, I want to
    >call another script that does a very long running task (10 hours +)
    >and print a message on the screen saying that the user will be emailed
    >on completion of the very long task. The script executing the very
    >long task will then email the user on completion.


    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
    was helpful to me in solving this problem.

    --
    \S -- -- http://www.chaos.org.uk/~sion/
    "Frankly I have no feelings towards penguins one way or the other"
    -- Arthur C. Clarke
    her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
    Sion Arrowsmith, Mar 13, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LarsenMTL
    Replies:
    4
    Views:
    688
    Eric Walstad
    Nov 4, 2004
  2. Replies:
    20
    Views:
    713
    Gunnar Hjalmarsson
    Jan 18, 2005
  3. Replies:
    12
    Views:
    376
    alpha_beta_release
    Aug 28, 2006
  4. kath
    Replies:
    4
    Views:
    585
    J. Gleixner
    Apr 9, 2007
  5. Ted Byers
    Replies:
    9
    Views:
    124
    Ted Byers
    Sep 16, 2008
Loading...

Share This Page