#11686: Race condition in matplotlib mkdir()
------------------------+---------------------------------------------------
   Reporter:  jdemeyer  |          Owner:  tbd          
       Type:  defect    |         Status:  needs_review 
   Priority:  minor     |      Milestone:  sage-4.7.2   
  Component:  packages  |       Keywords:               
Work_issues:            |       Upstream:  N/A          
   Reviewer:            |         Author:  John Palmieri
     Merged:            |   Dependencies:               
------------------------+---------------------------------------------------
Changes (by newvalueoldvalue):

  * status:  new => needs_review
  * author:  => John Palmieri


Old description:

> I regularly see this error when testing on the buildbot:
> {{{
> sage -t -long  -force_lib devel/sage/doc/de/tutorial/tour_functions.rst
> **********************************************************************
> File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/devel
> /sage-main/doc/de/tutorial/tour_functions.rst", line 24:
>     sage: plot(f, 0, 2)
> Exception raised:
>     Traceback (most recent call last):
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/ncadoctest.py",
> line 1231, in run_one_test
>         self.run_one_example(test, example, filename, compileflags)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/sagedoctest.py",
> line 38, in run_one_example
>         OrigDocTestRunner.run_one_example(self, test, example, filename,
> compileflags)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/ncadoctest.py",
> line 1172, in run_one_example
>         compileflags, 1) in test.globs
>       File "<doctest __main__.example_0[5]>", line 1, in <module>
>         plot(f, Integer(0), Integer(2))###line 24:
>     sage: plot(f, 0, 2)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/misc/displayhook.py", line 174, in displayhook
>         print_obj(sys.stdout, obj)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/misc/displayhook.py", line 142, in print_obj
>         print >>out_stream, `obj`
>       File "sage_object.pyx", line 154, in
> sage.structure.sage_object.SageObject.__repr__
> (sage/structure/sage_object.c:1463)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/plot/plot.py", line 1081, in _repr_
>         self.show()
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/misc/decorators.py", line 426, in wrapper
>         return func(*args, **kwds)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/plot/plot.py", line 1723, in show
>         self.save(DOCTEST_MODE_FILE, **kwds)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/misc/decorators.py", line 426, in wrapper
>         return func(*args, **kwds)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/plot/plot.py", line 2453, in save
>         figure = self.matplotlib(**options)
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/sage/plot/plot.py", line 1930, in matplotlib
>         from matplotlib.figure import Figure, figaspect
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/matplotlib/figure.py", line 18, in <module>
>         from axes import Axes, SubplotBase, subplot_class_factory
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/matplotlib/axes.py", line 18, in <module>
>         import matplotlib.contour as mcontour
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/matplotlib/contour.py", line 21, in <module>
>         import matplotlib.texmanager as texmanager
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/matplotlib/texmanager.py", line 72, in <module>
>         class TexManager:
>       File
> "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
> /site-packages/matplotlib/texmanager.py", line 92, in TexManager
>         os.mkdir(texcache)
>     OSError: [Errno 17] File exists:
> '/tmp/dot_sage.WboXjWq0ow/matplotlib-1.0.1/tex.cache'
> }}}
>
> The problem looks to be the following race condition in the matplotlib
> code:
> {{{
>     if not os.path.exists(texcache):
>         os.mkdir(texcache)
> }}}

New description:

 I regularly see this error when testing on the buildbot:
 {{{
 sage -t -long  -force_lib devel/sage/doc/de/tutorial/tour_functions.rst
 **********************************************************************
 File
 "/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/devel
 /sage-main/doc/de/tutorial/tour_functions.rst", line 24:
     sage: plot(f, 0, 2)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_0[5]>", line 1, in <module>
         plot(f, Integer(0), Integer(2))###line 24:
     sage: plot(f, 0, 2)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/misc/displayhook.py", line 174, in displayhook
         print_obj(sys.stdout, obj)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/misc/displayhook.py", line 142, in print_obj
         print >>out_stream, `obj`
       File "sage_object.pyx", line 154, in
 sage.structure.sage_object.SageObject.__repr__
 (sage/structure/sage_object.c:1463)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/plot/plot.py", line 1081, in _repr_
         self.show()
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/misc/decorators.py", line 426, in wrapper
         return func(*args, **kwds)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/plot/plot.py", line 1723, in show
         self.save(DOCTEST_MODE_FILE, **kwds)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/misc/decorators.py", line 426, in wrapper
         return func(*args, **kwds)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/plot/plot.py", line 2453, in save
         figure = self.matplotlib(**options)
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/sage/plot/plot.py", line 1930, in matplotlib
         from matplotlib.figure import Figure, figaspect
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/matplotlib/figure.py", line 18, in <module>
         from axes import Axes, SubplotBase, subplot_class_factory
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/matplotlib/axes.py", line 18, in <module>
         import matplotlib.contour as mcontour
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/matplotlib/contour.py", line 21, in <module>
         import matplotlib.texmanager as texmanager
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/matplotlib/texmanager.py", line 72, in <module>
         class TexManager:
       File
 
"/Users/buildbot/build/sage/bsd-1/bsd_64_upgrade/build/sage-4.5.3-4.7.1/local/lib/python
 /site-packages/matplotlib/texmanager.py", line 92, in TexManager
         os.mkdir(texcache)
     OSError: [Errno 17] File exists:
 '/tmp/dot_sage.WboXjWq0ow/matplotlib-1.0.1/tex.cache'
 }}}

 The problem looks to be the following race condition in the matplotlib
 code:
 {{{
     if not os.path.exists(texcache):
         os.mkdir(texcache)
 }}}

 -----

 New spkg available at

 [http://sage.math.washington.edu/home/palmieri/SPKG/matplotlib-1.0.1.p0.spkg]

--

Comment:

 I've created a new spkg, link in the ticket description. I'm posting the
 diff here for review purposes.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11686#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to