[pygtk] File doesn't get closed: how to make sure that the object is 'freed'?

Stefan Stuhr gnomelists at sstuhr.dk
Mon Mar 16 07:55:03 WST 2009


søn, 15 03 2009 kl. 23:38 +0100, skrev Arjen Nienhuis:
> Hi,
> 
> I'm using the glib bindings of poppler through python. Everything works fine:
> 
> - I can open a pdf file
> - I can render it through pycairo
> 
> but after that the file stays open. For each use of
> 'document_new_from_file' one extra file descriptor is used (according
> to lsof). If I leave the program running for a while, I get 'too many
> open files'.
> 
> [...]
> 
> Can I check if doc gets freed? Can I force it to free?

I don't have any experience with these bindings, but try this:

import os
import poppler

for i in range(1000000):
    uri = "file://" + os.path.abspath("test.pdf")
    doc = poppler.document_new_from_file(uri, None)
    del doc

> [...]
> 
> Groeten, Arjen

Stefan



More information about the pygtk mailing list