(I'm using Python 3.6.5)
I'm debugging a production problem which seems to be caused by __del__ not being called. I added debug messages in both __init_ and __del__ and it turned out sometimes (when the product problem was hit) __del__ is not called.
I Googled a lot and based on my understanding there are 2 cases where __del__ may not be called:
os._exit()- Cyclic reference (or reference loop)
I'm quite sure we did not call os._exit() so I suspect the problem was most likely caused by some reference loop but I failed to figure out what a reference loop would look like. So could someone help give an example of reference loop which can prevent __del__ from being called?
__del__from executing, as can force-killing a program withkillor similar means.__del__should be called?__del__is not guaranteed to be called if the object is still alive when the interpreter exists. This is in the docs