Skip to content

Commit dfae0b3

Browse files
committed
Migrate to new plugin system, and only import multiprocessing if needed
1 parent 7cf62f6 commit dfae0b3

File tree

1 file changed

+15
-1
lines changed
  • src/mkdocs_git_revision_date_localized_plugin

1 file changed

+15
-1
lines changed

src/mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import re
1010
import os
1111
import time
12-
import multiprocessing
1312
from pathlib import Path
1413

1514
from mkdocs import __version__ as mkdocs_version
@@ -59,6 +58,20 @@ def __init__(self):
5958
self.last_revision_commits = {}
6059
self.created_commits = {}
6160

61+
def on_startup(self, *, command: str, dirty: bool) -> None:
62+
"""
63+
Run on startup.
64+
65+
Note that "The presence of an on_startup method (even if empty)
66+
migrates the plugin to the new system where the plugin object is
67+
kept across builds within one mkdocs serve."
68+
69+
Args:
70+
command (str): The mkdocs command being run.
71+
dirty (bool): Whether the build is dirty.
72+
"""
73+
pass
74+
6275
def on_config(self, config: config_options.Config, **kwargs) -> Dict[str, Any]:
6376
"""
6477
Determine which locale to use.
@@ -153,6 +166,7 @@ def on_config(self, config: config_options.Config, **kwargs) -> Dict[str, Any]:
153166
return config
154167

155168
def parallel_compute_commit_timestamps(self, files, original_source: Optional[Dict] = None, is_first_commit=False):
169+
import multiprocessing
156170
pool = multiprocessing.Pool(processes=min(10, multiprocessing.cpu_count()))
157171
results = []
158172
for f in files:

0 commit comments

Comments
 (0)