Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/mutmut/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from math import ceil
from multiprocessing import Lock
from multiprocessing import Pool
from multiprocessing import get_start_method
from multiprocessing import set_start_method
from os import makedirs
from os import walk
Expand Down Expand Up @@ -1229,8 +1230,18 @@ def stop_all_children(mutants: list[tuple[SourceFileMutationData, str, int | Non
m.stop_children()


# used to copy the global mutmut.config to subprocesses
set_start_method("fork")
# Guard against "context has already been set" when mutmut.__main__ is
# re-executed (see GH-466).
if get_start_method(allow_none=True) is None:
set_start_method("fork")
elif "mutmut.__main__" not in sys.modules:
warnings.warn(
"mutmut.__main__ was re-executed because it was not cached in "
"sys.modules. Use `mutmut run` instead of `python -m mutmut run` "
"to avoid this.",
stacklevel=1,
)

START_TIMES_BY_PID_LOCK = Lock()


Expand Down
Loading