geo-data / medin-portal

Implementation of the MEDIN portal
http://portal.oceannet.org
3 stars 1 forks source link

Mako templates cause uncaught `KeyError` in multithreaded environments under load #34

Open homme opened 11 years ago

homme commented 11 years ago

This thread suggests that the problem is in the use of the TemplateLookup class: it should only be instantiated once and used from a globally referenced variable which is currently not the case.

Note that the problem only manifests itself in a multithreaded persistent environment that is under load.

An example stack trace is as follows:

http://portal.oceannet.org/search/spatial/tms/1.0.0/bathymetry/12/4119/3273.png at 2012-09-01 04:42:11,217:
The application encountered an unhandled exception
File /data/www/medin_portal/python/errata.py, line 58, in __call__
return self.app(environ, start_response)
File /data/www/medin_portal/python/selector.py, line 161, in __call__
return app(environ, start_response)
File /data/www/medin_portal/python/medin/spatial.py, line 184, in tilecache
svc = get_tileservice(environ)
File /data/www/medin_portal/python/medin/spatial.py, line 168, in get_tileservice
template = lookup.get_template(mappath)
File /data/www/medin_portal/python/mako/lookup.py, line 85, in get_template
return self.__load(srcfile, uri)
File /data/www/medin_portal/python/mako/lookup.py, line 127, in __load
self.__collection[uri] = Template(uri=uri, filename=posixpath.normpath(filename), lookup=self, module_filename=(self.modulename_callable is not None and self.modulename_callable(filename, uri) or None), **self.template_args)
File /data/www/medin_portal/python/mako/template.py, line 84, in __init__
del sys.modules[self.module_id]
KeyError: 'config_tilecache_cfg'