On Mon, Oct 18, 2004 at 07:06:31PM -0400, Jesse Pavel wrote: > > > I'm trying to structure my Quixote SCGI program so that each child > process started by the SCGI server acquires a few resources when it > begins, and explicitly releases them when the parent process > terminates. I'm not sure where is the proper place to put the code > that releases resources, considering that I normally terminate the > parent with a SIGINT. > > When I do that, what happens to the child processes, which are, I > presume, blocking while waiting for the passed file descriptor from > the server? Is there a "clean" method of releasing resources, based > on catching a Python exception somewhere, or perhaps I need to trap > a signal in each child? Have you implemented and are you using a sub-class of quixote.publish.Publisher? That's what I do. My Publisher subclass usually contains: 1. A start_request method, which is called just before request processing. It shoves the resources my request processing needs into the request object. 2. A __del__ method, which is called when the process and the Publisher are destroyed. It cleans up my resources. Of course, you will want to put a debugging message in the __del__ method to make sure that it is being called. As I recall, there is a bit of weirdness about the __del__ method. A print statement placed directly in the __del__ method works. But, a call to another function containing a print statement does not. At least, that's what I recall. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman