mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4286 from tk0miya/4279_multiproc_and_logging
Fix #4279: Sphinx crashes with pickling error when run with multiple …
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -30,6 +30,8 @@ Bugs fixed
|
||||
* #4249: PDF output: Pygments error highlighting increases line spacing in
|
||||
code blocks
|
||||
* #1238: Support ``:emphasize-lines:`` in PDF output
|
||||
* #4279: Sphinx crashes with pickling error when run with multiple processes and
|
||||
remote image
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -82,6 +82,10 @@ def convert_serializable(records):
|
||||
r.msg = r.getMessage()
|
||||
r.args = ()
|
||||
|
||||
location = getattr(r, 'location', None)
|
||||
if isinstance(location, nodes.Node):
|
||||
r.location = get_node_location(location) # type: ignore
|
||||
|
||||
|
||||
class SphinxWarningLogRecord(logging.LogRecord):
|
||||
"""Log record class supporting location"""
|
||||
@@ -415,21 +419,26 @@ class WarningLogRecordTranslator(logging.Filter):
|
||||
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
|
||||
record.location = get_node_location(location)
|
||||
elif location and ':' not in location:
|
||||
record.location = '%s' % self.app.env.doc2path(location)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_node_location(node):
|
||||
# type: (nodes.Node) -> str
|
||||
(source, line) = get_source_line(node)
|
||||
if source and line:
|
||||
return "%s:%s" % (source, line)
|
||||
elif source:
|
||||
return "%s:" % source
|
||||
elif line:
|
||||
return "<unknown>:%s" % line
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class ColorizeFormatter(logging.Formatter):
|
||||
def format(self, record):
|
||||
# type: (logging.LogRecord) -> str
|
||||
|
||||
Reference in New Issue
Block a user