Hacker News new | ask | show | jobs
by bobbyi_settv 2054 days ago
I think the idiomatic way is with weakref https://docs.python.org/3/library/weakref.html

Particularly note "finalize provides a straight forward way to register a cleanup function to be called when an object is garbage collected"