tdickenson at devmail.geminidataloggers.co.uk
Mon Feb 26 13:12:10 CET 2001
David Bolen <db3l at fitlinxx.com> wrote:
>"Alexander Semenov" <sav at ulmen.mv.ru> writes:
>> No, python python implements reference counting. Then file object loose all
>> references it will del-ed. I think file object handles del correctly and
>> corresponding handle.
>Just as a general point, you can't guarantee when _del_ will be
>called. While the current CPython implementations (even in 2.x I
>think) trigger that when the RC hits zero, there's no guarantees, and
>it might not be called until later (or even until Python's process
>terminates). I'm not sure if JPython/Jython does it immediately even
>in their current releases.
>So depending on the criticality of controlling the close, you may want
>to handle it yourself explicitly, particularly if you are writing data
>that might otherwise not get flushed until (possibly) much later.
That is less true than it was before 2.0...
2.0 takes care not to be recursive when deallocating recursive data
structures. This is achieved by moving dead objects onto a separate
list, and deleting things iteratively.
If you have more than one thread manipulating deeply recursive data
structures then it is possible for deallocations to be delayed, and
then actually handled by a thread other than the one that released the
Im still suprised noone else finds this as much of a problem as I do.
tdickenson at geminidataloggers.com
More information about the Python-list