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"
Particularly note "finalize provides a straight forward way to register a cleanup function to be called when an object is garbage collected"
No comments yet.