improve coverage a bit

This commit is contained in:
Anthony Sottile 2021-11-14 09:35:49 -08:00
parent 639dfe1671
commit bb3c8d2607
3 changed files with 50 additions and 21 deletions

View file

@ -3,6 +3,7 @@ import collections
import errno
import itertools
import logging
import multiprocessing.pool
import signal
import tokenize
from typing import Dict
@ -15,11 +16,6 @@ from flake8 import exceptions
from flake8 import processor
from flake8 import utils
try:
import multiprocessing.pool
except ImportError:
multiprocessing = None # type: ignore
Results = List[Tuple[str, int, int, str, Optional[str]]]
LOG = logging.getLogger(__name__)
@ -40,13 +36,6 @@ SERIAL_RETRY_ERRNOS = {
}
def _multiprocessing_is_fork() -> bool:
"""Class state is only preserved when using the `fork` strategy."""
return bool(
multiprocessing and multiprocessing.get_start_method() == "fork"
)
class Manager:
"""Manage the parallelism and checker instances for each plugin and file.
@ -113,7 +102,9 @@ class Manager:
# - we're processing a diff, which again does not work well with
# multiprocessing and which really shouldn't require multiprocessing
# - the user provided some awful input
if not _multiprocessing_is_fork():
# class state is only preserved when using the `fork` strategy.
if multiprocessing.get_start_method() != "fork":
LOG.warning(
"The multiprocessing module is not available. "
"Ignoring --jobs arguments."