Exceptions when closing a file

kyosohma at gmail.com kyosohma at gmail.com
Tue Mar 20 16:53:57 EDT 2007


On Mar 20, 4:26 pm, Bruno Desthuilliers
<bdesth.quelquech... at free.quelquepart.fr> wrote:
> kyoso... at gmail.com a écrit :
>
>
>
> > On Mar 20, 12:25 pm, Steven D'Aprano
> > <s... at REMOVE.THIS.cybersource.com.au> wrote:
>
> >>Closing a file can (I believe) raise an exception. Is that documented
> >>anywhere? I've spent a lot of frustrating time trying to track this down,
> >>with no luck, which suggests that either my google-foo is weak or that it
> >>isn't documented. Is IOError the only exception it can raise?
>
> >>The only thing I have found is this:
>
> >>http://mail.python.org/pipermail/python-bugs-list/2004-November/02603...
>
> >>Out of curiosity, is there a simple way to demonstrate close() raising an
> >>exception that doesn't involve messing about with disk quotas?
>
> >>--
> >>Steven.
>
> > I've never had any problems closing a file. Maybe you need to flush it
> > before you close it?
>
> Usually, closing the file flushes the buffer. At least with buffered
> files, but that's the most common situation AFAICT.
>
> > Are you running threads that access the file in
> > ad hoc fashion or something else out of the ordinary? Is this some
> > sort of long running process writing a large file?
>
> Might just be that there's no more available storage space.

Very true...I was fishing for more information to be able to give a
more specific answer. And I was tired, so I didn't think of
everything. Good call, you guys!

Mike




More information about the Python-list mailing list