It is __del__ calling twice for some instances?
Max Yuzhakov
gmt at sdf-eu.org
Wed Aug 16 17:14:36 EDT 2006
Duncan Booth пишет:
DB> Not with the code which you gave as an example, but in the general case
DB> yes, the only guarantee that Python gives about the __del__ method on an
DB> instance is that it will be called zero, one or more than one times during
DB> the run of the program. In practice there are various situations where
DB> __del__ will not be called, but it is only called multiple times if you
DB> resurrect the object during a call to __del__.
No, only presented code in __del__ do
increment of global variable del_cnt.
DB> The output from your stat function could, of course, also be generated by
DB> creating and destroying lots of foo objects in another thread. If a foo was
DB> both created and destroyed between the first two print statements, and
DB> another one was created and destroyed in the middle of the evaluation of
DB> the last print statement then you could see the output you described
DB> without any multiple __del__ calls in the same object.
No, it's a single-threaded code.
DB> You should post a working code sample which generates your output if you
DB> want a more useful answer.
I'm sorry for mess with a code. I have forgotten to write, that is
only fragments for demonstration of essence of a question.
Real code in this module has 880 lines and I shall not
abuse your time. I shall try to solve a problem by debuger.
And thank for Your answer!
--
GMT More Then ...
More information about the Python-list
mailing list