[Python-Dev] Re: weakref callback vs gc vs threads (original) (raw)
Neil Schemenauer nas at arctrix.com
Fri Oct 29 19:24:34 CEST 2004
- Previous message: [Python-Dev] TRUNK UNFROZEN (release is done)
- Next message: [Python-Dev] Re: weakref callback vs gc vs threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Taking this to email. Carrying out discussions via the SF bug tracker sucks.]
Comment By: Tim Peters (tim_one)
[Neil] > I had to change PyWeakrefClearRef() since it was also > clearing the weakref list of the trash object.
That was really its purpose. If a trash weakref with a callback isn't removed from the referent's list of weakrefs, then the callback will trigger when PyObjectClearWeakRefs() is invoked on the referent. The purpose of PyWeakrefClearRef() was to ensure that the callback never triggers.
But it's okay of the callback triggers, as long as the callback doesn't reference trash.
> Now it just sets wrobject to PyNone.
That won't stop the callback from triggering. It also means (see earlier comment) that PyObjectClearWeakRefs() will never removed the weakref from the list either, although I'm not sure that does real harm.
I'm trying to figure out PyObject_ClearWeakRefs() right now.
> I also made some serious simplifications to gcmodule by > just treating trash weakref objects with callbacks the same > as objects with del methods (i.e. move them to the > finalizers list and then do the transitive closure of that set).
Does that mean they can end up in gc.garbage too? If so, I don't think that's sellable.
I think so. That can be easily changed though. What we can't do is invoke those callbacks.
Neil
- Previous message: [Python-Dev] TRUNK UNFROZEN (release is done)
- Next message: [Python-Dev] Re: weakref callback vs gc vs threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]