[MapProxy] mbtiles > KML SuperOverlay on Apache throws ValueError

Simeon Nedkov simeon at ndkv.nl
Mon Jul 8 14:12:44 PDT 2013

Hi list,

I'm new to MapProxy and am loving it thus far: it's easy to install and 
configure and it's very light and fast compared to GeoServer. I am, 
however, experiencing some inconveniences.

I am serving an mbtiles cache made with TileMill from a GeoTIFF as a KML 
SuperOverlay. I've setup a layer and the corresponding cache as:

   - name: vening
     title: vening
     sources: [vening_cache]

     sources: []
     grids: [GLOBAL_MERCATOR]
       type: mbtiles
       filename: /home/ubuntu/mapproxy/data/vening.mbtiles

I've integrated MapProxy in Apache through mod_wsgi as

WSGIPythonHome /home/ubuntu/mapproxy
WSGIScriptAlias /mapproxy /home/ubuntu/mapproxy/mymapproxy/config.py

<Directory /home/ubuntu/mapproxy>
   Order deny,allow
   Allow from all

I fetch the KML SuperOverlay at

and load it in Google Earth. The overlay itself is displayed perfectly 
fine: I can zoom in all the way and new tiles are retrieved as needed. 
However, I get a bunch of red crosses over the globe that is not covered 
by the overlay. When I follow one of the faulty URLs (for example 
for the first time I get a blank page i.e. a transparent .png. However, 
when I follow it a second time (thereby emulating a zoom or pan in 
Google Earth) I get an Internal Server Error. Opening the Apache log 
reveals a Python ValueError

[Mon Jul 08 21:00:15 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Mon Jul 08 21:00:15 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Mon Jul 08 21:00:15 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 
Python/2.7.3 configured -- resuming normal operations
[Mon Jul 08 21:00:28 2013] [error] [client] mod_wsgi 
(pid=16499): Exception occurred processing WSGI script 
[Mon Jul 08 21:00:28 2013] [error] [client] Traceback (most 
recent call last):
[Mon Jul 08 21:00:28 2013] [error] [client]   File 
line 181, in __call__
[Mon Jul 08 21:00:28 2013] [error] [client]     return 
resp(environ, start_response)
[Mon Jul 08 21:00:28 2013] [error] [client]   File 
"/home/ubuntu/mapproxy/lib/python2.7/site-packages/mapproxy/response.py", line 
151, in __call__
[Mon Jul 08 21:00:28 2013] [error] [client] 
self.response.seek(0, 2) # to EOF
[Mon Jul 08 21:00:28 2013] [error] [client] ValueError: I/O 
operation on closed file

What is going on? I don't get these errors with the mapproxy-util 
serve-develop server: it simply returns transparent .png images all the 
time. I'm guessing that something is borked with my Apache 
configuration; I have little experience with it and especially mod_wsgi.

I'm running Apache 2.2.22 and MapProxy 1.5 (in a virtualenv) on Ubuntu 
12.04 (Amazon instance).

I've also given the apache user right to MapProxy's cache directories 
and the data directory that stores the mbtiles cache with
sudo chown www-data /path_to_cache
sudo chgrp www-data /path_to_cache

Any help is greatly appreciated!


PS The map you see depicts the journey of Vening Meinesz, a Dutch 
geophysicist and geodesist who measured the Earth's gravity field from a 
submarine and thereby discovered continental drift 

More information about the MapProxy mailing list