[mod_python] Trouble spawning a long running process...

Gustavo Córdova Avila gustavo.cordova at q-voz.com
Wed Jun 2 10:35:00 EDT 2004


> 
> Hi all,
> 
> I'm attempting to spawn a process in my mod_python function.  
> I want to run a long-running script in a seperate process
> while returning the process id to the client quickly. 
> However, the spawned process goes zombie (defunct), I 
> think when the mod_python function finishes sending the 
> response to the client.  Here's how I'm spawning the process:
> process_id = os.spawnl(os.P_NOWAIT, BUILDISO_COMMAND)
> and when I check the status of the spawned process:
> # ps ax
> [...]
>  4229 ?        S      0:00 /usr/sbin/httpd
>  4237 ?        Z      0:00 [httpd] <defunct>
> It is defunct.  (The parent is dead, long live the parent!)
> 
> Do any of you have advice for a good way to keep the user 
> from having to wait for long processes to finish before
> seeing a response from mod_python?

I had a problem like this in another life, albeit it was with CGI,
but the principal might be the same.  The child process needs to
detach from it's parent, you might need to do the double-fork
trick.

> 
> ...
> 
> As a bit of background, the spawned script is creating an iso 
> file approx 45MB for the client to download (later). 
>

No wonder.  My app was doing a massive mailing to some list
subscribers, using a decidedly unefficient algorithm to do the
sending.

> 
> Many thanks for your time, wisdom and suggestions.
> 
> Best regards,
> 
> Eric.
>

You're welcome, hope this helps.

-gus




More information about the Mod_python mailing list