Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bffb15d

Browse files
committed
Revert back to using inkscape once for each SVG->PNG conversion, rather than running it as a server, which mysteriously causes a deadlock on some systems.
1 parent 43ffb29 commit bffb15d

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -112,45 +112,9 @@ def convert(*args):
112112
converter['eps'] = make_external_conversion_command(cmd)
113113

114114
if matplotlib.checkdep_inkscape() is not None:
115-
class SVGConverter:
116-
def __init__(self):
117-
self._count = 0
118-
self._process = None
119-
120-
def get_process(self):
121-
# Since Inkscape can leak a little memory, we run X
122-
# conversions and then shut it down and start up a new
123-
# Inkscape.
124-
if self._count == 0:
125-
if self._process is not None:
126-
self._process.communicate('quit\n')
127-
self._process = subprocess.Popen(['inkscape', '-z', '--shell'],
128-
stdin=subprocess.PIPE,
129-
stdout=subprocess.PIPE,
130-
stderr=subprocess.STDOUT)
131-
self.read_to_end(self._process.stdout)
132-
self._count = 10
133-
self._count -= 1
134-
return self._process
135-
136-
def __call__(self, old, new):
137-
process = self.get_process()
138-
process.stdin.write('%s --export-png=%s\n' % (old, new))
139-
process.stdin.flush()
140-
self.read_to_end(process.stdout)
141-
142-
def read_to_end(self, buf):
143-
ret = ''
144-
lastchar = ''
145-
while True:
146-
char = buf.readline(1)
147-
if char == '>' and lastchar == '\n':
148-
break
149-
ret += char
150-
lastchar = char
151-
return ret
152-
153-
converter['svg'] = SVGConverter()
115+
cmd = lambda old, new: \
116+
['inkscape', '-z', old, '--export-png', new]
117+
converter['svg'] = make_external_conversion_command(cmd)
154118

155119
def comparable_formats():
156120
'''Returns the list of file formats that compare_images can compare

0 commit comments

Comments
 (0)