473,811 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Dec 13 '06 #1
0 937

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2594
by: Peter Abel | last post by:
I have an application, which is an instance of a class with a deeply nested object hierarchy. Among others one method will be executed as a thread, which can be stopped. Everything works fine except that when deleting the main instance - after the thread has been stopped - the __del__ method will not be carried out. Tough a simple example works as expected: >>> class A: .... def __init__(self):
13
2040
by: Emmanuel | last post by:
Hi, I run across this problem, and couldn't find any solution (python 2.2.2) : Code : =========== from __future__ import generators >>> class titi:
2
1438
by: David MacQuigg | last post by:
I'm __del__() to decrement a count of instances of a class whenever an instance is deleted, and I'm getting very erratic behavior. This is in CPython, which I am told has no problem with reference counts getting out-of-sync with the deletion of instances. The behavior of __del__() seems to be very sensitive to the exact sequence of commands. The example below is a repeatable test case. It might be possible to simplify this further,...
0
1184
by: Christopher J. Bottaro | last post by:
I get this exception when I run the following code: Exception exceptions.TypeError: 'super() argument 1 must be type, not None' in <bound method Txrposdn.__del__ of <__main__.Txrposdn object at 0xf6f7118c>> ignored Here is the code: class Txrposdn(PRI.BasicBatch):
0
1142
by: phil | last post by:
> you haven't answered my question, btw: why are you using __del__ > to do something that the garbage collector should do for you? After more reading it seems I have made an ass of my self on this subject. Here is my problem at length. I teach high school geometry. I have created a program with a scalable graph on which to make drawings to illustrate concepts. This is working well.
13
1413
by: Torsten Bronger | last post by:
Hallöchen! When my __del__ methods are called because the program is being terminated, I experience difficulties in calling functions that I need for a clean shutdown of my instances. So far, there has been only one of these functions, and a class-local alias solved the problem. However, now there are many of them. Is there a way to detect whether the program is being terminated? (In this case, I wouldn't care and return from...
8
8383
by: Gregor Horvath | last post by:
Hi, I do not understand why __del__ does not get executed in the following example. test.py: #!/usr/bin/python class A(object): def __init__(self):
1
1494
by: Erwan Adam | last post by:
Hello all, Can someone reproduce this bug ... I use : python Python 2.4.3 (#2, Sep 18 2006, 21:07:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. First test :
6
2878
by: George Sakkis | last post by:
I'm baffled with a situation that involves: 1) an instance of some class that defines __del__, 2) a thread which is created, started and referenced by that instance, and 3) a weakref proxy to the instance that is passed to the thread instead of 'self', to prevent a cyclic reference. This probably sounds like gibberish so here's a simplified example: ==========================================
11
1484
by: Jason Baker | last post by:
I have a class that I need to do some finalization on when it dies. I know I can use the __del__ method, but I seem to recall that it impedes garbage collection. Is this the case? (keep in mind that my code aims to be compatible with python 2.3 to python 2.5)
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.