Add some caching to texmanager.py?

This was in a long-running session with very large

    > memory allocations, but it dawned on me that
    > get_dvipng_version(self) should cache its return value.
    > There's no point in forcing a popen() call every single
    > time, is there?

It already does cache the version

    def get_dvipng_version(self):
        if self.dvipngVersion is not None: return self.dvipngVersion
        sin, sout = os.popen2('dvipng --version')
        ...snip...

I think the reason it is failing in your case is that is each renderer
creation creates a new TexManager instance. The cache should be on a
class basis and not on a per instance basis (slaps self on head).
Moving

        self.dvipngVersion = None

to the class level and out of __init__ should suffice. I made this
change, and similar changes in texmanager and backend_agg, so that
caching is shared between instances. Update from CVS and let me know
if everything still works :slight_smile:

    > I also just saw pylab crash when a user was trying to
    > run with $PWD being something he didn't have write
    > access to. Are there any checks in the code to fall
    > back to /tmp or something sensible if texmanager can't
    > write the temp files it needs? Sorry for not giving a
    > traceback, but I only saw this on someone else's screen
    > while helping them, and for some odd reason it's not
    > happening on my box.

This is probably failing on the tex/latex temporary files. I spent
some time initially trying to figure out how to get these to go into
~/.tex.cache but didn't succeed. If anyone knows how to direct
tex/latex to put the various *.aux, *.log, etc, files in a specified
directory, pass it my way.

Thanks,
JDH

John Hunter wrote:

"Fernando" == Fernando Perez <Fernando.Perez@...76...> writes:

    > This was in a long-running session with very large
    > memory allocations, but it dawned on me that
    > get_dvipng_version(self) should cache its return value.
    > There's no point in forcing a popen() call every single
    > time, is there?

It already does cache the version

    def get_dvipng_version(self):
        if self.dvipngVersion is not None: return self.dvipngVersion
        sin, sout = os.popen2('dvipng --version')
        ...snip...

I think the reason it is failing in your case is that is each renderer
creation creates a new TexManager instance. The cache should be on a
class basis and not on a per instance basis (slaps self on head).
Moving

        self.dvipngVersion = None

to the class level and out of __init__ should suffice. I made this
change, and similar changes in texmanager and backend_agg, so that
caching is shared between instances. Update from CVS and let me know
if everything still works :slight_smile:

swamped at the moment, but I'll let you know if I see problems when I get a chance.

    > I also just saw pylab crash when a user was trying to
    > run with $PWD being something he didn't have write
    > access to. Are there any checks in the code to fall
    > back to /tmp or something sensible if texmanager can't
    > write the temp files it needs? Sorry for not giving a
    > traceback, but I only saw this on someone else's screen
    > while helping them, and for some odd reason it's not
    > happening on my box.

This is probably failing on the tex/latex temporary files. I spent
some time initially trying to figure out how to get these to go into
~/.tex.cache but didn't succeed. If anyone knows how to direct
tex/latex to put the various *.aux, *.log, etc, files in a specified
directory, pass it my way.

I don't really know, sorry. My texpertise is pretty limited, as you know :slight_smile:

Thanks for the fixes!

f

John Hunter wrote:

This is probably failing on the tex/latex temporary files. I spent
some time initially trying to figure out how to get these to go into
~/.tex.cache but didn't succeed. If anyone knows how to direct
tex/latex to put the various *.aux, *.log, etc, files in a specified
directory, pass it my way.

From "man tex" on FC3, the section on environment variables:

       TEXMFOUTPUT
              Normally, TeX puts its output files in the current directory.
              If any output file cannot be opened there, it tries to open it
              in the directory specified in the environment variable TEXM-
              FOUTPUT. There is no default value for that variable. For
              example, if you say tex paper and the current directory is not
              writable, if TEXMFOUTPUT has the value /tmp, TeX attempts to
              create /tmp/paper.log (and /tmp/paper.dvi, if any output is
              produced.)

I get this when mpl complains about not being able to create a .ttffont.cache (or whatever it's called) file. I'll submit a bug on the tracker later.

Cheers!
Andrew

···

On Jun 21, 2005, at 1:09 PM, John Hunter wrote:

    > I also just saw pylab crash when a user was trying to
    > run with $PWD being something he didn't have write
    > access to. Are there any checks in the code to fall
    > back to /tmp or something sensible if texmanager can't
    > write the temp files it needs? Sorry for not giving a
    > traceback, but I only saw this on someone else's screen
    > while helping them, and for some odd reason it's not
    > happening on my box.

This is probably failing on the tex/latex temporary files. I spent
some time initially trying to figure out how to get these to go into
~/.tex.cache but didn't succeed. If anyone knows how to direct
tex/latex to put the various *.aux, *.log, etc, files in a specified
directory, pass it my way.