This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients konrad.schwarz, mark.dickinson, pitrou
Date 2021-03-03.16:39:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614789566.91.0.756372884445.issue43383@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-03-03 16:39:26mark.dickinsonsetrecipients: + mark.dickinson, pitrou, konrad.schwarz
2021-03-03 16:39:26mark.dickinsonsetmessageid: <1614789566.91.0.756372884445.issue43383@roundup.psfhosted.org>
2021-03-03 16:39:26mark.dickinsonlinkissue43383 messages
2021-03-03 16:39:26mark.dickinsoncreate