Mark Dickinson <dicki...@gmail.com> added the comment:
If I understand correctly, the reported bug is that you're seeing a weakref callback being executed after the weakref.ref instance it's attached to is deleted. Is that correct? Do you have a minimal example we can use to reproduce the effect? Without such an example, there's not much of a realistic path to moving this forward. Without the code: I can't see a plausible mechanism by which the callback could execute after the weakref.ref has ceased to exist. However, my suspicion is that that's not what's actually happening here. I suspect that when you say "after the corresponding weak reference has been deleted with del", that the "del" statement you refer to is not actually deleting the last reference to the weakref.ref object, so the weakref still exists after the "del". One easy way that this could happen is if the weakref is part of a reference cycle (and I know from personal experience that it's horribly easy to accidentally *create* reference cycles via weakref callbacks, especially if those callbacks refer to instance methods). Furthermore, if the weakref exists as part of a cycle and that cycle is being collected by the garbage collector, I could see how the callback could be sometimes executed and sometimes not depending on the exact order in which the cycle is cleaned up. ---------- nosy: +mark.dickinson, pitrou _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43383> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com