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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Holger Joukl

    #1

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


    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 adressiertwurde ,
    verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
    sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sindnicht
    gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
    garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Siebitte
    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.


Working...