[reportlab-users] too many open files with inline images

Volker Haas volker.haas at brainbot.com
Mon Aug 11 06:26:58 EDT 2008


I get an error (too many open files) when using lots of inline images
inside paragraphs.

Sample code:

from reportlab.platypus.paragraph import Paragraph
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.lib.styles import ParagraphStyle

import os
doc = SimpleDocTemplate('test.pdf')
elements = []

for count in range(1024):
print len(os.listdir("/proc/%d/fd" % os.getpid()))
p = Paragraph('text <img src="math2.png" width="2cm" height="0.5cm"
/>' , ParagraphStyle('Normal'))
elements.append(p)
doc.build(elements)

OUTPUT:

Traceback (most recent call last):
File "test_fd.py", line 13, in <module>
OSError: [Errno 24] Too many open files: '/proc/32336/fd'

If the print statement is omitted (which isn't really platform
independent ;)) I get an IOError (IOError: Cannot open resource
"math.png" fileName=math.png) . But I am pretty sure this only happens
because no new file handle could be aquired. The sample code works if
less images are used (my machines limit for open file handles is 1024
per process).
I am not attaching the sample image, b/c the sample code behaves in the
same way when the image file is not existent.

Regards,
Volker

--
volker haas brainbot technologies ag
fon +49 6131 2116394 boppstraße 64
fax +49 6131 2116392 55118 mainz
volker.haas at brainbot.com http://www.brainbot.com/



More information about the reportlab-users mailing list