> > I got another clue, it seems that the python process runs out of
> > file handles. After 10k requests (via ab -c 1 -n 10000) i got
> > several "not found" io exceptions like "/dev/urandom not found",
> > TemplateError: Template xy not found and this one : Error Opening
> > file /path/to/geoip/GeoIP.dat
> > Maybe that is why the mod_python setup runs fine, due to the restart
> > for each request.
> Also make sure you aren't still loading mod_python into Apache if
> using mod_wsgi as the presence of mod_python can in some cases cause
> mod_wsgi to misbehave.
No, mod_python is deactivated, but the file descriptor leak was imho
the problem.. 

The Fix, for the record :)

--- a/apps/catalog/templatetags/composedimage.py
+++ b/apps/catalog/templatetags/composedimage.py
@@ -105,7 +105,7 @@ class ComposedImage(object):
     def _open_svg_as_image(self, fn, width, height, position, factor,
offset): import cairo
         import rsvg
-        file = tempfile.mkstemp(suffix='.png', prefix='tmc_svg_')[1]
+        fd,file = tempfile.mkstemp(suffix='.png', prefix='tmc_svg_')
         fn = smart_str(fn)
         svg = rsvg.Handle(file=fn)
 
@@ -123,7 +123,10 @@ class ComposedImage(object):
         surface.write_to_png(file)
         image = Image.open(file, "r")
         image.convert("RGBA")
+
+        os.close(fd)
         os.unlink(file)

Thanks,
  Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to