any way to know when the program is exiting?

Ovidiu Predescu ovidiu at cup.hp.com
Wed Jul 28 21:35:37 EDT 1999


Hi,

I was wondering if there is any way in a __del__ method to know when it's
invoked on the way out, as a result of the program going away?

I have a __del__ method of a class that sends a message to a global variable.
It happens that on the way out, that value in that variable is destroyed before
the __del__ methods of my instances are invoked. The result is that I have a
bogus value that doesn't respond to the usual methods anymore. How can I
prevent sending messages to that object?

A possible solution would be to use atexit() but this doesn't work if the user
program that's using my library replaces it with its own function.

Any ideas?


Thanks,
-- 
Ovidiu Predescu <ovidiu at cup.hp.com>
http://andromeda.cup.hp.com/  (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/






More information about the Python-list mailing list