durusmail: quixote-users: Releasing Resources w/ SCGI
Releasing Resources w/ SCGI
2004-10-18
2004-10-19
2004-10-19
2004-10-19
2004-10-19
Releasing Resources w/ SCGI
Tim Golden
2004-10-19
[Dave Kuhlman]

[... snip re subclassing Publisher and adding __del__ ...]

| 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.

Well one caveat about __del__ is that there's no guarantee that
it will be called, although it generally is in my experience.
Quote from library ref: "It is not guaranteed that __del__()
methods are called for objects that still exist when the
interpreter exits." I believe that a good alternative is
the sys.exitfunc / atexit module approach, so long as you can make
it work with your object scopes etc.

(I realise that the suggestion about a print statement probably
reflected this uncertainty but I thought I'd just make it
explicit.)

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

reply