Destructor?

  • Thread starter Gabriel Rossetti
  • Start date
G

Gabriel Rossetti

Hello everyone,

we are writing an application that needs some cleanup to be done if the
application is quit, normally (normal termination) or by a signal like
SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm
mistaken there is no guarantee as of when it will be called, and some
objects may have already been released (at lease I've had trouble in the
past accessing certain objects from inside __del__, probably since the
parent class's __del__ has to be called first, then it's objects are
already released by the time I need to do something with them). Another
method would be to implement something using the signal module and have
a callback that does all the cleanup when the app. is
quit/terminated/interrupted and have all the child classes override that
with their cleanup code.

What is the community's point of view on the subject?

Thanks,
Gabriel
 
T

Thomas Guettler

Duncan said:
[*] except of course for things like power failure. You simply cannot
catch *all* terminations.

And 'kill -SIGKILL' can't be caught, since this signal never reaches the
process. The os just removes the processes.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top