26390: destructor doesn't get called on class instances stored in DependableDict

Hi,

I’m refactoring some old stuff and moving a lot of previously node-based stuff into pure python. I was going to use a DependableDict to store some class instances, but it looks like __del__() doesn’t get called on instances when .clear() is called on the containing DependableDict.

Is this behavior expected?

Thanks!

Hi flowb

In general, it’s not great practice to rely on __del__ because it’s invoked by the garbage collector, whose timing is not guaranteed. If possible, it’s recommended to use the context manager.

Still, I can check this out if you’d like to send a simple example of what you’re trying to do. Post here or send to ivan@derivative.ca

My simple test worked as expected, so a reference may be being stored elsewhere. I dunno. Happy to take a look.

import TDStoreTools

class destro():
	def __del__(self):
		print(self)

d = TDStoreTools.DependDict()

d[0] = destro()

d.clear()

Hi Ivan, I emailed you the code. Thanks.