From ce473897a30e05ab20284b9c4fd3dc1d8664d1fc Mon Sep 17 00:00:00 2001 From: Vangelis Banos Date: Sun, 25 Feb 2018 20:24:25 +0000 Subject: [PATCH] Disable Jinja2 template auto_reload for higher performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every time we run a JS behavior, we load a Jinja2 template. By default, Jinja2 has option `auto_reload=True`. This mean that every time a template is requested the loader checks if the source file changed and if yes, it will reload the template. For higher performance it’s possible to disable that. Also note that Jinja caches 400 templates by default. Ref: http://jinja.pocoo.org/docs/2.10/api/ In Brozzler, we don't make changes to JS templates while the system is running. So, there is no point in having auto_reload=True. --- brozzler/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brozzler/__init__.py b/brozzler/__init__.py index a8d0b33..6d901a0 100644 --- a/brozzler/__init__.py +++ b/brozzler/__init__.py @@ -258,7 +258,7 @@ def jinja2_environment(behaviors_dir=None): 'js-templates')) else: _loader=jinja2.PackageLoader('brozzler', 'js-templates') - _jinja2_env = jinja2.Environment(loader=_loader) + _jinja2_env = jinja2.Environment(loader=_loader, auto_reload=False) _jinja2_env.filters['json'] = json.dumps return _jinja2_env