# Buggy code
def _parallel_task(self, files_or_modules):
    # Prepare configuration for child linters.
    child_config = self._get_jobs_config()

    children = []
    manager = multiprocessing.Manager()
    tasks_queue = manager.Queue()
    results_queue = manager.Queue()

    # Send files to child linters.
    expanded_files = self.expand_files(files_or_modules)

    # do not start more jobs than needed
    for _ in range(min(self.config.jobs, len(expanded_files))):
        child_linter = ChildLinter(args=(tasks_queue, results_queue, child_config))
        child_linter.start()
        children.append(child_linter)

    for files_or_module in expanded_files:
        path = files_or_module["path"]
        tasks_queue.put([path])

    # collect results from child linters
    failed = False
    for _ in expanded_files:
        try:
            result = results_queue.get()
        except Exception as ex:
            print(
                "internal error while receiving results from child linter",
                file=sys.stderr,
            )
            print(ex, file=sys.stderr)
            failed = True
            break
        yield result

    # Stop child linters and wait for their completion.
    for _ in range(self.config.jobs):
        tasks_queue.put("STOP")
    for child in children:
        child.join()

    if failed:
        print("Error occurred, stopping the linter.", file=sys.stderr)
        sys.exit(32)


# Traceback (UnicodeDecodeError)
~/devel/openage % pylint --jobs=2 openage
No config file found, using default configuration
************* Module openage.__init__
W: 20, 0: TODO pylint: disable=wrong-import-position (fixme)
************* Module openage.__main__
W: 11, 0: TODO remove this once all multiprocessing has been eliminated: (fixme)
************* Module openage.default_dirs
W: 14, 0: TODO: use os.pathsep for multipath variables (fixme)
W: 42, 0: TODO: other windows paths (fixme)
Process ChildLinter-3:
Traceback (most recent call last):
File "/usr/lib64/python3.6/tokenize.py", line 390, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 40: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 129, in file_build
stream, encoding, data = open_source_file(path)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 49, in open_source_file
encoding = detect_encoding(byte_stream.readline)[0]
File "/usr/lib64/python3.6/tokenize.py", line 431, in detect_encoding
encoding = find_cookie(first)
File "/usr/lib64/python3.6/tokenize.py", line 395, in find_cookie
raise SyntaxError(msg)
File "<string>", line None
SyntaxError: invalid or missing encoding declaration for 'openage/cabextract/lzxd.cpython-35m-x86_64-linux-gnu.so'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 896, in get_ast
return MANAGER.ast_from_file(filepath, modname, source=True)
File "/usr/lib64/python3.6/site-packages/astroid/manager.py", line 80, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 137, in file_build
'{error}', modname=modname, path=path, error=exc))
File "/usr/lib64/python3.6/site-packages/astroid/util.py", line 30, in reraise
six.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib64/python3.6/site-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 129, in file_build
stream, encoding, data = open_source_file(path)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 49, in open_source_file
encoding = detect_encoding(byte_stream.readline)[0]
File "/usr/lib64/python3.6/tokenize.py", line 431, in detect_encoding
encoding = find_cookie(first)
File "/usr/lib64/python3.6/tokenize.py", line 395, in find_cookie
raise SyntaxError(msg)
astroid.exceptions.AstroidSyntaxError: Python 3 encoding specification error or unknown encoding:
invalid or missing encoding declaration for 'openage/cabextract/lzxd.cpython-35m-x86_64-linux-gnu.so'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 208, in run
result = self._run_linter(file_or_module[0])
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 237, in _run_linter
linter.check(file_or_module)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 726, in check
self._do_check(files_or_modules)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 844, in _do_check
ast_node = self.get_ast(filepath, modname)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 900, in get_ast
args=str(ex.error))
File "/usr/lib64/python3.6/site-packages/pylint/utils.py", line 359, in add_message
'Message %s must provide line, got None' % msgid)
pylint.exceptions.InvalidMessageError: Message E0001 must provide line, got None
Process ChildLinter-2:
Traceback (most recent call last):
File "/usr/lib64/python3.6/tokenize.py", line 390, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 24: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 129, in file_build
stream, encoding, data = open_source_file(path)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 49, in open_source_file
encoding = detect_encoding(byte_stream.readline)[0]
File "/usr/lib64/python3.6/tokenize.py", line 431, in detect_encoding
encoding = find_cookie(first)
File "/usr/lib64/python3.6/tokenize.py", line 395, in find_cookie
raise SyntaxError(msg)
File "<string>", line None
SyntaxError: invalid or missing encoding declaration for 'openage/cabextract/cabchecksum.cpython-35m-x86_64-linux-gnu.so'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 896, in get_ast
return MANAGER.ast_from_file(filepath, modname, source=True)
File "/usr/lib64/python3.6/site-packages/astroid/manager.py", line 80, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 137, in file_build
'{error}', modname=modname, path=path, error=exc))
File "/usr/lib64/python3.6/site-packages/astroid/util.py", line 30, in reraise
six.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib64/python3.6/site-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 129, in file_build
stream, encoding, data = open_source_file(path)
File "/usr/lib64/python3.6/site-packages/astroid/builder.py", line 49, in open_source_file
encoding = detect_encoding(byte_stream.readline)[0]
File "/usr/lib64/python3.6/tokenize.py", line 431, in detect_encoding
encoding = find_cookie(first)
File "/usr/lib64/python3.6/tokenize.py", line 395, in find_cookie
raise SyntaxError(msg)
astroid.exceptions.AstroidSyntaxError: Python 3 encoding specification error or unknown encoding:
invalid or missing encoding declaration for 'openage/cabextract/cabchecksum.cpython-35m-x86_64-linux-gnu.so'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 208, in run
result = self._run_linter(file_or_module[0])
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 237, in _run_linter
linter.check(file_or_module)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 726, in check
self._do_check(files_or_modules)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 844, in _do_check
ast_node = self.get_ast(filepath, modname)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 900, in get_ast
args=str(ex.error))
File "/usr/lib64/python3.6/site-packages/pylint/utils.py", line 359, in add_message
'Message %s must provide line, got None' % msgid)
pylint.exceptions.InvalidMessageError: Message E0001 must provide line, got None
^CTraceback (most recent call last):
File "/usr/lib/python-exec/python3.6/pylint", line 11, in <module>
load_entry_point('pylint==1.7.2', 'console_scripts', 'pylint')()
File "/usr/lib64/python3.6/site-packages/pylint/__init__.py", line 13, in run_pylint
Run(sys.argv[1:])
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 1300, in __init__
linter.check(args)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 729, in check
self._parallel_check(files_or_modules)
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 797, in _parallel_check
for result in self._parallel_task(files_or_modules):
File "/usr/lib64/python3.6/site-packages/pylint/lint.py", line 772, in _parallel_task
result = results_queue.get()
File "<string>", line 2, in get
File "/usr/lib64/python3.6/multiprocessing/managers.py", line 757, in _callmethod
kind, result = conn.recv()
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 250, in recv
buf = self._recv_bytes()
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 407, in _recv_bytes
buf = self._recv(4)
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 379, in _recv
chunk = read(handle, remaining)
KeyboardInterrupt

# Fixed code
def _parallel_task(self, files_or_modules):
    # Prepare configuration for child linters.
    child_config = self._get_jobs_config()

    children = []
    manager = multiprocessing.Manager()
    tasks_queue = manager.Queue()
    results_queue = manager.Queue()

    # Send files to child linters.
    expanded_files = []
    for descr in self.expand_files(files_or_modules):
        modname, filepath, is_arg = descr["name"], descr["path"], descr["isarg"]
        if self.should_analyze_file(modname, filepath, is_argument=is_arg):
            expanded_files.append(descr)

    # do not start more jobs than needed
    for _ in range(min(self.config.jobs, len(expanded_files))):
        child_linter = ChildLinter(args=(tasks_queue, results_queue, child_config))
        child_linter.start()
        children.append(child_linter)

    for files_or_module in expanded_files:
        path = files_or_module["path"]
        tasks_queue.put([path])

    # collect results from child linters
    failed = False
    for _ in expanded_files:
        try:
            result = results_queue.get()
        except Exception as ex:
            print(
                "internal error while receiving results from child linter",
                file=sys.stderr,
            )
            print(ex, file=sys.stderr)
            failed = True
            break
        yield result

    # Stop child linters and wait for their completion.
    for _ in range(self.config.jobs):
        tasks_queue.put("STOP")
    for child in children:
        child.join()

    if failed:
        print("Error occurred, stopping the linter.", file=sys.stderr)
        sys.exit(32)