示例#1
0
def _worker_initialize(linter, arguments=None):
    global _worker_linter  # pylint: disable=global-statement
    _worker_linter = linter

    # On the worker process side the messages are just collected and passed back to
    # parent process as _worker_check_file function's return value
    _worker_linter.set_reporter(reporters.CollectingReporter())
    _worker_linter.open()

    # Patch sys.path so that each argument is importable just like in single job mode
    _patch_sys_path(arguments or ())
示例#2
0
def _worker_initialize(
    linter: bytes, arguments: Union[None, str, Sequence[str]] = None
) -> None:
    """Function called to initialize a worker for a Process within a multiprocessing Pool

    :param linter: A linter-class (PyLinter) instance pickled with dill
    :param arguments: File or module name(s) to lint and to be added to sys.path
    """
    global _worker_linter  # pylint: disable=global-statement
    _worker_linter = dill.loads(linter)

    # On the worker process side the messages are just collected and passed back to
    # parent process as _worker_check_file function's return value
    _worker_linter.set_reporter(reporters.CollectingReporter())
    _worker_linter.open()

    # Patch sys.path so that each argument is importable just like in single job mode
    _patch_sys_path(arguments or ())