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

H

Holger Joukl

Hi all,

I've recently run into a problem that I haven't seen with python 1.5.2 and
python 2.3.
It seems that under certain conditions __del__ does not get immediately
called when a local variable goes out of scope.

I ended up with deadlocks in a threaded application because a locked
section
was supposed to be entered from within __del__ but apparently the same
thread
(the main thread, in that case) was already holding that lock.

The result looked really strange with the main thread entering the locked
section and
then suddenly the delayed call of __del__ taking control, also wanting to
acquire
the lock but never being able to.

Unfortunately I fail to put together a minimal example.

Anyway: Is relying on __del__ getting called immediately when the refcount
drops to 0 a no-no?
If so should that maybe be prominently stated in the docs?

Cheers,
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top