3

I used the spawn function from the following post: Indefinite daemonized process spawning in Python

I'm writing a cgi script that takes in inputs, manipulates them, and then outputs a success page. One of the manipulative functions calls an executable that takes a little while to finish. As a result, when an individual submits a request, it simple hangs on the html page until completed.

In my def main() function, I do the following:

def main():
    <call a bunch of little functions here>
    print <All the success information here>
    <spawn the daemon process here>

The issue is that with that ordering, it prints the success information 3 times probably because of the forking. (but executable is running in the background as it should). If i put the daemon process before the html printing, it causes it to hang as it used to defeating the purpose of spawning the background process.

Does anyone have any ideas?

Also, quick theory question about forking, when fork is called, does it re-run the entire function it was called from again? So if I spawn the daemon process, will the forked processes, spawn the ?

Community
  • 1
  • 1
de1337ed
  • 3,113
  • 12
  • 37
  • 55

0 Answers0