[pypy-dev] "OSError: [Errno 10] No child processes"

Paolo Giarrusso p.giarrusso at gmail.com
Wed Jan 12 02:49:10 CET 2011


On Tue, Jan 11, 2011 at 22:09, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
> 2011/1/11 Armin Rigo <arigo at tunes.org>:
>> The secondary problem that we have is what to do when file.__del__
>> gets an exception from calling close().  Is it ok to just ignore it?
>> FWIW in CPython, file.__del__ also prints an error message if close()
>> raises an exception.  So from that point of view there is nothing to
>> fix in PyPy, apart maybe making the error message a bit more explicit
>> (CPython prints "close failed in file object destructor:...").
>
> The io module chose to silence the error;
> I suggest to do the same, even if the reasoning is different
> from the comment below::
>
> class IOBase:
>    def __del__(self):
>        """Destructor.  Calls close()."""
>        # The try/except block is in case this is called at program
>        # exit time, when it's possible that globals have already been
>        # deleted, and then the close() call might fail.  Since
>        # there's nothing we can do about such failures and they annoy
>        # the end users, we suppress the traceback.

I propose that PyPy keeps reporting the error for files opened in any
write mode, because then an error on close might mean that an I/O
error happened (it is possible in some scenarios on Linux, see below
[1]); the programmer thus need to explicitly close the file and check
for exceptions. Having writable files closed by __del__ also sounds
like a bad idea if any buffering is involved, because close() time
becomes unpredictable.
Those are mostly arguments against __del__ _silently_ calling close();
but when the potential bug is triggered, i.e. you hit an I/O error,
it's even more important to report it to the user.
I also propose that any error is ignored for read-mode files - because
then why should we care for it? The original error message talked
about a read-mode file handle.

[1] From the close(2) man page:
"Not checking the return value of close() is a common but nevertheless
serious programming error.  It is quite possible that errors on a
previous write(2) operation are first reported at the final close().
Not checking the return value when closing the file may lead to silent
loss of data.  This can especially be observed with NFS and with disk
quota."

Cheers,
-- 
Paolo Giarrusso - Ph.D. Student
http://www.informatik.uni-marburg.de/~pgiarrusso/



More information about the Pypy-dev mailing list