# Buggy code
def filter(self, record):  # type: ignore
    # type: (SphinxWarningLogRecord) -> bool
    if isinstance(record, logging.LogRecord):
        record.__class__ = (
            SphinxWarningLogRecord  # force subclassing to handle location
        )

    location = getattr(record, "location", None)
    if isinstance(location, tuple):
        docname, lineno = location
        if docname and lineno:
            record.location = "%s:%s" % (self.app.env.doc2path(docname), lineno)
        elif docname:
            record.location = "%s" % self.app.env.doc2path(docname)
        else:
            record.location = None
    elif isinstance(location, nodes.Node):
        (source, line) = get_source_line(location)
        if source and line:
            record.location = "%s:%s" % (source, line)
        elif source:
            record.location = "%s:" % source
        elif line:
            record.location = "<unknown>:%s" % line
        else:
            record.location = None
    elif location and ":" not in location:
        record.location = "%s" % self.app.env.doc2path(location)

    return True


# Traceback (PicklingError)
$ sphinx-build -j 2 -b html source build
Running Sphinx v1.6.5
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [ 50%] foo
reading sources... [100%] index

looking for now-outdated files... none found
pickling environment... done
checking consistency... /private/tmp/docs/source/foo.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] index

waiting for workers...
Process Process-1:
Traceback (most recent call last):
File "/Users/sfranklin/Python/Python-2.7.13/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/Users/sfranklin/Python/Python-2.7.13/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/Users/sfranklin/.virtualenvs/sphinx/lib/python2.7/site-packages/sphinx/util/parallel.py", line 94, in _process
pipe.send((failed, collector.logs, ret))
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

# Fixed code
def filter(self, record):  # type: ignore
    # type: (SphinxWarningLogRecord) -> bool
    if isinstance(record, logging.LogRecord):
        record.__class__ = (
            SphinxWarningLogRecord  # force subclassing to handle location
        )

    location = getattr(record, "location", None)
    if isinstance(location, tuple):
        docname, lineno = location
        if docname and lineno:
            record.location = "%s:%s" % (self.app.env.doc2path(docname), lineno)
        elif docname:
            record.location = "%s" % self.app.env.doc2path(docname)
        else:
            record.location = None
    elif isinstance(location, nodes.Node):
        record.location = get_node_location(location)
    elif location and ":" not in location:
        record.location = "%s" % self.app.env.doc2path(location)

    return True