[python-win32] Q: daemon spawn from within apache cgi blocks parent process

replytodirk@web.de replytodirk at web.de
Tue May 24 00:43:32 CEST 2005


Hi all!

I want to create a daemon process from within a python cgi script running on
apache/win32. This daemon's lifetime is longer than that of the creating cgi
script - of course, because the script starts the daemon, writes some html
code to stdout and then exits. This simple task kept me busy for weeks!

What I'm doing in the script is to spawn a new process with
win32process.CreateProcess() or subprocess.Popen() and then it writes html
code which dynamically creates a web-page consisting of 3 frames. The frame
references are pointing to the very same script which will then be executed
by apache multiple times until all frames are rendered (this times bypassing
the daemon creation code).

The strange thing is that the script execution for rendering the last frame
is delayed until the daemon process exits! I completely do not understand
this. The daemon process starts and the script is executed repeatedly for
all frame references but the last one, leaving the browser in a 'page
loading' state. As soon as the daemon process exits, the script is executed
again to generate the last frame and the page is loaded completely. When the
script doesn't start the daemon, the frames are filled without any delay.

Does anybody have an idea what goes wrong here? Is there any connection
between a parent and a child process which has to be released before the
processes can die independently? Are there any Apache-specific things to
handle when spawning processes?

Your help would be greatly appreciated!
Dirk



More information about the Python-win32 mailing list