[Tilecache] make dir error
Fredrik Lundh
fredrik at pythonware.com
Thu Apr 10 10:52:00 EDT 2008
> i just tried myself having a look into the source code, but i am a totally rookie in python. surrounding the self.makedirs() statement with a try: / finally: did not do the job and resulted in another error.
you want
try:
...
except OSError:
pass
instead of try-finally (the latter catches exceptions and reraises them).
the real reason for this is that os.makedirs isn't quite robust enough
for parallel use; it does catch "already exists" errors (errno 17) for
intermediate directory levels, but not for the final node. to fix
this, TileCache could do something like:
import errno, os
def safe_mkdir(path):
if os.path.isdir(path):
return
try:
os.makedirs(path)
except OSError, e:
if e.errno != errno.EEXIST:
raise
and then use safe_mkdir instead of any isdir/makedirs combo.
</F>
More information about the Tilecache
mailing list