GNOME Bugzilla – Bug 568427
"gio.Error: Too many open files" without too many open files
Last modified: 2009-02-08 19:27:32 UTC
Please describe the problem: When we use the gio wrapper, it raises a "gio.Error: Too many open files" after a while. And we don't have too many open files. Steps to reproduce: This snippet of code raises the exception: from gio import File, FILE_ATTRIBUTE_STANDARD_NAME g_file = File('.') while True: g_file.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME) Actual results: This code raises the exception. Expected results: I tried the same thing in C and i didn't have any problem (no g_error after a while). It's just with the python wrapper. Does this happen every time? yes Other information:
This is because .defs file lacks '(caller-owns-return #t)'. We need to revise all GIO files for that, I guess the problem is very widespread. In PyGTK it is not a case (at least mostly) because of the floating reference. Note that even after this bug is fixed, your test program is strictly speaking not correct. It depends on implementation details of CPython, namely that when a last reference to an object is deleted, the object is instantly destroyed. This is not the case on e.g. Jython.
This is horrible. Seems like PyGIO leaks about everything. To make it worse, GIO documentation doesn't properly specify when the returned object should and when shouldn't be unreffed...
Created attachment 127491 [details] [review] half-complete fix This patch adds a ton of 'caller-own-returns', plus makes constructor of gio.File not leak. 100% not complete. Reviewing is a must. By the way, the attached test program now works as expected.
Paul, I've applied the patch and made some tests, plus I've been checking with GIO docs, it looks like a good job as usual. I think you should commit
If you can, please scan over the patched .defs file and look for the methods that should have 'caller-owns-return' but which I missed. There are almost certainly a few such.
Created attachment 128237 [details] [review] more complete fix I've also added a pointer to the override file in the defs, so it's easier for everybody to see what has been overridden and where.
I think it reached that size (and mixes together different fixes) when it is easier to commit and sort it out later. I briefly read through the patch and it looked fine to me.
Sending ChangeLog Sending gio/gfile.override Sending gio/gfileinfo.override Sending gio/gio.defs Sending gio/gio.override Sending gobject/gobjectmodule.c Sending gobject/pygobject.c Sending gobject/pygtype.c Transmitting file data ........ Committed revision 1002.