Thanks for the responses everyone. More below inline... On Fri, Mar 27, 2009 at 9:12 AM, John Hunter <jdh2...@gmail.com> wrote:
> On Fri, Mar 27, 2009 at 5:54 AM, Darren Dale <dsdal...@gmail.com> wrote: > >> >> It might not be too much trouble to protect RcParams and its data, >> although I dont know how disruptive it would be to the mpl codebase and to >> users for rcParams to begin returning copies of things like font lists. >> > > > In addition to the rc params, I suspect some of the caching we do at the > module level, eg in agg > > > class RendererAgg(RendererBase): > > texd = maxdict(50) # a cache of tex image rasters > _fontd = maxdict(50) > > might be what is hurting here. Karen, could you try editing > site-packages/matplotlib/backends/backend_agg.py and moving these two lines > into the __init__method so they are at the instance level rather than the > class level. Eg, > > def __init__(self, width, height, dpi): > if __debug__: verbose.report('RendererAgg.__init__', > 'debug-annoying') > RendererBase.__init__(self) > self.texd = maxdict(50) # a cache of tex image rasters > self._fontd = maxdict(50) > > and see if that helps. Yes, this change appears to fix the problem. I created a standalone script to recreate the problem. The script starts several threads. Each thread enters a loop generating a (different) png file. With the original matplotlib code, the threads seem unable to complete 50 iterations without the exception being raised. (I tried the script at least a dozen times, it never finished successfully with 50 iterations. Usually failed before 5, but once made it as high as 20, so I bumped it up to 50 and that seemed to ensure it would fail before finishing). With the above change to make the texd and _fontd caches per-instance, the script has finished successfully 4 times. Seems pretty convincing evidence that it fixes the problem. > Also, make sure you have disabled usetex in matplotlibrc, since the use of > the filesystem for caching the tex datafiles is probably not thread safe. > My guess is that the font cache on the file system is not thread safe > either, but this may only affect the first run of mpl after a clean install. > Not sure what matplotlibrc is? I found a file /usr/share/matplotlib/matplotlib.conf that has usetex set to False. Is that it? If so I guess it's been disabled all along, this is not something I have fiddled with. > Also, as Eric suggests, a freestanding script which is thread enabled > (preferably just using mpl and the standard threading library rather than > django et al) which uses the agg backend that we could use for debugging > would be very helpful. > Understood, and I did make a standalone script (plus a set of pickle files for the data to graph) to recreate it. I can zip them up and send them somewhere, or open a ticket and attach it there, or whatever. Let me know what would be most convenient/helpful. Thanks! Karen
------------------------------------------------------------------------------
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel