Matplotlib error when starting printing in multiprocessor mode
I am using python Multiprocess.Pool to plot some data using multiple processes like this:
class plotDriver:
def plot(self, parameterList):
numberOfWorkers = len(parameterList)
pool = Pool(numberOfWorkers)
pool.map(plotWorkerFunction, parameterList)
pool.close()
pool.join()
this is a simplified version of my class, the driver also contains other stuff that I prefer to skip. plotWorkderFunction
is a single threaded function that imports matplotlib and does all the plots and shape adjustments and saves the plots in one pdf file and each worker does not interact with the other.
I need to call this plot function multiple times as I have many parameters, for example:
parameters = [parameterList0, parameterList1, ... parameterListn]
for param in parameters:
driver = PlotDriver()
driver.plot(param)
If parameters
only contains one parameterList
(the for loop only runs once), the code looks fine. But it consistently fails whenever it parameters
contains more than one element, with a second error message in the second loop.
Traceback (most recent call last):
File "plot.py", line 59, in <module>
plottingDriver.plot(outputFile_handle)
File "/home/yingryic/PlotDriver.py", line 69, in plot
pool.map(plotWrapper, workerParamList)
File "/home/yingryic/.conda/envs/pp/lib/python2.7/multiprocessing/pool.py", line 251, in map
return self.map_async(func.iterable, chunksize).get()
File "/home/yingryic/.conda/envs/pp/python2.7/multiprocessing/pool.py", line 567, in get
raise self._value
RuntimeError: In set_text: could not load glyph
X Error: BadIDChoice (invalid resouce ID chosen for this connection) 14
Extension: 138 (RENDER)
Minor opcode: 17 (RenderCreateGlyphSet)
Resouce id: 0xe00002
: Fatal IO error: client killed
any idea what is going wrong and how should i fix it?
source to share
No one has answered this question yet
See similar questions:
or similar: