Skip to content

Commit

Permalink
core: enforce fork as mp context
Browse files Browse the repository at this point in the history
as we need to share all resources of the linter's
main process with the child tasks running the checks.
Otherwise things like the CONSTANTS interface will
be simply reinitialized within the child's space,
but ignoring all the added things from the tweaks
runs by the main process.

This will be mandatory from python 3.14

Closes #721
Closes #722

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Mar 3, 2025
1 parent fd3933a commit 26262f8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions oelint_adv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ def rule_applicable(rule):
groups = group_files(args.files, args.mode)
if not any(groups):
return []
# Starting with python 3.14 the default way of starting the mp Pool
# will be 'forkserver' - see https://docs.python.org/3.14/library/multiprocessing.html#contexts-and-start-methods
# But in our setup we will need to share e.g. the CONSTANTS object into
# the checks running in the Pool
# Hence, we enforce fork
if mp.get_start_method() != 'fork':
mp.set_start_method('fork')
with mp.Pool(processes=min(args.jobs, len(groups))) as pool:
try:
issues = flatten(pool.map(partial(group_run, quiet=args.quiet, fix=args.fix,
Expand Down

0 comments on commit 26262f8

Please sign in to comment.