[newbie] File handle destroyed before pending write is executed?
mwilson at the-wire.com
Tue Sep 16 17:44:09 CEST 2003
In article <bk20ru$edg$01$1 at news.t-online.com>,
Peter Otten <__peter__ at web.de> wrote:
>Mel Wilson wrote:
>> In article <bjrtos$brd$03$1 at news.t-online.com>,
>> Peter Otten <__peter__ at web.de> wrote:
>>>(By the way, I think the __del__() method is superfluous)
>> I wish it were, but no. The Python definition leaves the
>> door open for implementations that garbage-collect only when
>> they sorely need to, [ ... ]
>> Rather say that logfile.__del__ is only half an answer.
>I don't understand this. Where is the difference between delaying the
>garbage collection of the logfile instance or its fh attribute?
What I was thinking was, logfile eventually gets
collected, and if it has the __del__ method as shown, the
file will at least get closed then. Without the __del__
method, the file will(?) get collected eventually but maybe
a long time after logfile. Not superfluous in terms of more
functionality than is necessary .. superfluous in terms of
more code than is used, I guess.
>On implementations where immediate gc is not guaranteed, the only realistic
>solution to avoid "dangling" open files would be to make the file closing
Very true. This is what I would call the whole answer.
More information about the Python-list