[Tilecache] Skip a tile if there is a server error
Adrian Popa
adrian_gh.popa at romtelecom.ro
Wed Nov 11 08:05:31 EST 2009
Hello,
My main problem is if I try to generate a file cache from my WMS server,
sometimes the process dies because of a HTTP 500 error. I would like to
add an override to generate the rest of the tiles if it gets such an
error (because the error happes from time to time and it isn't a
disaster if one tile is broken).
# python /var/www/html/tilecache/tilecache_seed.py -f rtc 1 10 --bbox
2255332.8831578,5336357.2739115,3306188.8761,6183726.4985628
...
08 (009472, 010444) = (3130860.6772 5508358.0046 3133306.6621
5510803.9895) [0.0830s : 22.518/s] 30529/148780
08 (009473, 010444) = (3133306.6621 5508358.0046 3135752.6470
5510803.9895) [0.0804s : 22.518/s] 30530/148780
Traceback (most recent call last):
File "/var/www/html/tilecache/tilecache_seed.py", line 9, in ?
TileCache.Client.main()
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Client.py",
line 162, in main
seed(svc, layer, map(int, args[1:3]), bboxlist ,
padding=options.padding, force = options.force, reverse = options.reverse)
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Client.py",
line 117, in seed
svc.renderTile(tile,force=force)
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Service.py",
line 138, in renderTile
data = layer.render(tile, force=force)
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Layer.py",
line 443, in render
return self.renderTile(tile)
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Layers/WMS.py",
line 29, in renderTile
tile.data, response = wms.fetch()
File
"/usr/lib/python2.4/site-packages/TileCache-2.10-py2.4.egg/TileCache/Client.py",
line 58, in fetch
response = self.client.open(urlrequest)
File "/usr/lib/python2.4/urllib2.py", line 364, in open
response = meth(req, response)
File "/usr/lib/python2.4/urllib2.py", line 471, in http_response
response = self.parent.error(
File "/usr/lib/python2.4/urllib2.py", line 402, in error
return self._call_chain(*args)
File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
File "/usr/lib/python2.4/urllib2.py", line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
I believe it should be a pretty straight-forward task to catch the
exception (in python) and just continue the loop as if the image was
generated - but I have no experience with python (I'm a perl person) -
so I'm asking for your help. Also, catching the exception should be done
in the function that expects the image to be generated - because
otherwise we would have to return something meaninful...
So, my questions are (if there is nobody willing to edit the code...):
1. where (in the stack trace) should I add the exception handler?
2. can I get a link to a good, short tutorial on Exception handling for
python? (I hope I can solve this without learning the language!) :)
My guess is I should edit somewhere around response =
self.client.open(urlrequest) - but I have no clue...
Thanks,
Adrian
More information about the Tilecache
mailing list