call of __del__ non-deterministic in python 2.4 (cpython)?

Holger Joukl Holger.Joukl at LBBW.de
Wed Dec 13 05:48:05 EST 2006


python-list-bounces+holger.joukl=lbbw.de at python.org schrieb am 13.12.2006
11:09:13:

> Holger Joukl wrote:
>
> > Anyway: Is relying on __del__ getting called immediately when the
refcount
> > drops to 0 a no-no?
>
> yes, but more importantly, relying on the refcount dropping to 0 when
> something goes out of scope is a major no-no.

In my particular use case I think can rule out the problematic situations,
except for the
object being referenced in the stack trace, but that won't put me into
problems (and
there were no exceptions at all when I ran into the deadlocks)

> > If so should that maybe be prominently stated in the docs?
>
> is it perhaps the color that made you miss the big bold boxes in the
> documentation?
>
>      http://docs.python.org/ref/customization.html#l2h-177
>
> </F>

I did read this but didn't think it applied to my situation. I'm quite
sure that the refcount of the local variable is 1 before the local scope
is left.
So let me rephrase the question: Even if I can make sure that non of the
problematic situtions apply, might it _still_ happen that __del__ gets
called
after some other code has already been "entered"?

Thanks,
Holger

Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.





More information about the Python-list mailing list