[Tilecache] pink tiles

Sylvain Pasche sylvain.pasche at camptocamp.com
Fri Mar 7 05:04:26 EST 2008


Hi,

I hit the "pink tiles" issue recently on a project. I'm using tilecache
revision 139 with mod_python.

Here's the exception I received from the server:

An error occurred: [Errno 17] File exists:
'/tmp/tilecache/teleatlas/04/000/000/432'
  File "/var/lib/python-support/python2.4/TileCache/Service.py", line
459, in modPythonHandler
    host )
  File "/var/lib/python-support/python2.4/TileCache/Service.py", line
443, in dispatchRequest
    return self.renderTile(tile, params.has_key('FORCE'))
  File "/var/lib/python-support/python2.4/TileCache/Service.py", line
402, in renderTile
    if (data): image = self.cache.set(tile, data)
  File "/var/lib/python-support/python2.4/TileCache/Cache.py", line 132,
in set
    os.makedirs(dirname)
  File "os.py", line 156, in makedirs
    makedirs(head, mode)
  File "os.py", line 156, in makedirs
    makedirs(head, mode)
  File "os.py", line 159, in makedirs
    mkdir(name, mode)


I used the attached patch to work around the issue (simply ignores the
mkdir exception in case of error). Maybe there's a better way to solve this.


Regards,
Sylvain

-------------- next part --------------
--- /var/lib/python-support/python2.4/TileCache/Cache.py.orig
+++ /var/lib/python-support/python2.4/TileCache/Cache.py
@@ -129,7 +129,11 @@
         filename = self.getKey(tile)
         dirname  = os.path.dirname(filename)
         if not self.access(dirname, 'write'):
-            os.makedirs(dirname)
+            try:
+                os.makedirs(dirname)
+            except OSError:
+                # Hack
+                pass
         tmpfile = filename + ".%d.tmp" % os.getpid()
         output = file(tmpfile, "wb")
         output.write(data)




More information about the Tilecache mailing list