Skip to content

Commit

Permalink
TEMP: Tried with multiprocessing -- not good since can't pickle embed…
Browse files Browse the repository at this point in the history
…ded function
  • Loading branch information
yarikoptic committed Dec 22, 2023
1 parent 016b730 commit a6081f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import re
import sys
import textwrap
from multiprocessing import Pool
from typing import (
Any,
Dict,
Expand Down Expand Up @@ -1240,7 +1241,18 @@ def _parse_file(filename: str) -> int:
options,
)

bad_count = sum(map(_parse_file, _find_files()))
njobs = os.cpu_count() or 1
if njobs:
# parse_file would be in subprocess(es)
with Pool(njobs) as pool:
results = pool.map(_parse_file, _find_files())
for result in results:
if isinstance(result, Exception):
raise result
bad_count = sum(results)
else:
# serial
bad_count = sum(map(_parse_file, _find_files()))

if summary:
print("\n-------8<-------\nSUMMARY:")
Expand Down

0 comments on commit a6081f2

Please sign in to comment.