del self vs self.__del__() - and what is the proper way to cleanup in python?
问题 I have a python script that contains a class. This class has a __del__ method for usual cleanup. If I delete the class during the normal execution of the script, I want some cleanup to be done. I also have a signal handler, that does some unusual cleanup. If the script was in the middle of executing something else when it received the signal, it needs to do some extra cleanup, followed by the regular cleanup. I noticed there is a difference between doing del self and self.__del__() . Namely,