Skip to content

Commit

Permalink
perf: Disable Jinja's auto_reload to reduce disk reads
Browse files Browse the repository at this point in the history
Any time a template is referenced, even though it's cached in memory, Jinja ends up doing a filesystem access, to check whether the template file has been modified and so would need to be recompiled.
But it's not even useful to be able to modify a template file on disk in the middle of a mkdocs build.
  • Loading branch information
oprypin authored Dec 23, 2020
1 parent d493d33 commit 3b28c58
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mkdocstrings/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ def __init__(self, directory: str, theme: str, custom_templates: Optional[str] =
if self.fallback_theme != "":
paths.append(themes_dir / self.fallback_theme)

self.env = Environment(autoescape=True, loader=FileSystemLoader(paths)) # type: ignore
self.env = Environment(
autoescape=True,
loader=FileSystemLoader(paths),
auto_reload=False, # Editing a template in the middle of a build is not useful.
) # type: ignore
self.env.filters["any"] = do_any
self.env.globals["log"] = get_template_logger()

Expand Down

0 comments on commit 3b28c58

Please sign in to comment.