Confusion with weakref, __del__ and threading

George Sakkis george.sakkis at gmail.com
Wed Jun 11 16:15:41 EDT 2008


On Jun 11, 2:01 pm, Rhamphoryncus <rha... at gmail.com> wrote:

> On Jun 11, 10:43 am, George Sakkis <george.sak... at gmail.com> wrote:
>
> > On Jun 11, 1:40 am, Rhamphoryncus <rha... at gmail.com> wrote:
> > > The trick here is that calling proxy.sleep(0.01) first gets a strong
> > > reference to the Mystery instance, then holds that strong reference
> > > until it returns.
>
> > Ah, that was the missing part; I thought that anything accessed
> > through a proxy didn't create a strong reference. The good thing is
> > that it seems you can get a proxy to a bounded method and then call it
> > without creating a strong reference to 'self':
>
> That's not right.  Of course a bound method has a strong reference to
> self, otherwise you'd never be able to call it.  There must be
> something else going on here.  Try using sys.setcheckinterval(1) to
> make threads switch more often.

I tried that and it still works; all objects die at the main thread.
Any other idea to break it ?

George



More information about the Python-list mailing list