[mod_python] Re: forks, daemons, and other beasts

Graham Dumpleton grahamd at dscpl.com.au
Sun Feb 12 05:34:51 EST 2006


On 12/02/2006, at 9:27 PM, Barry Burns wrote:

> Graham Dumpleton wrote:
>>
>> On 12/02/2006, at 2:55 PM, Barry Burns wrote:
>>
>>>> The documentation for thread says that
>>>> When the main thread exits, it is system defined whether the other
>>>> threads survive. On SGI IRIX using the native thread  
>>>> implementation,
>>>> they survive. On most other systems, they are killed without  
>>>> executing
>>>> try ... finally clauses or executing object destructors.
>>>> I tested this and indeed whatever is called with
>>>> thread.start_new_thread it will die if execution reaches the end of
>>>> the original program.
>>>
>>> This may be completely off, but how about sending the  
>>> notification, closing the connection to the client, then  
>>> unzipping in the same thread?
>>
>> I doubt the client socket connection would be closed off if one  
>> did that
>> and if no content length was specified, the client browser would  
>> probably
>> hang waiting for socket connection to close and thus would not  
>> necessarily
>> render what it had already received. In other words, the content  
>> handler
>> has to return for socket connection to get closed off. That is  
>> also presuming
>> that keep alive is not enabled.
>>
>> Graham
> I think you might've misunderstood what I meant, or else I said it  
> wrong. I'm talking about sending some data along, then manually  
> doing whatever the mod_python equivalent of shutdown(socket,  
> SHUT_RDWR) is, then performing what you need to do (in this case  
> unzipping). AFAIK, this guarantees that the connection is closed by  
> sending FIN, rather than the alternative, simply closing it (which  
> will leave the connection hanging if the fd is open in any other  
> threads or processes).
>
> Another possibility is dumping the zip file into an incoming  
> directory, then having a cron job or scheduled task periodically  
> unzip any files in that directory. I don't know if this would work  
> for your application, though.

I knew what you meant. It simply isn't possible in mod_python/Apache  
to say
shutdown the socket connection. There are potentially various layers  
of Apache
filters and other stuff between the mod_python handler and the socket  
and
mod_python doesn't have a direct handle on the socket that it can  
manipulate.
Thus, in the context of mod_python, it isn't that simple.

Graham


More information about the Mod_python mailing list