Daniel Nogradi
nogradi at gmail.com
Sun Feb 12 06:03:47 EST 2006
> >>>> 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. One more thought: it seems that if MaxRequestsPerChild is 1, then anything threaded from the script handling the request will die when the script ends, but if MaxRequestsPerChild is N > 1, then it doesn't die, so everything seems to be okay. But what if the request is exactly the Nth for that particular child, then it will be the same as before, and the thread will die, won't it?
|