Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rare race condition in makedirs with parallel processes #5225

Closed
timj opened this issue Oct 12, 2015 · 1 comment
Closed

Rare race condition in makedirs with parallel processes #5225

timj opened this issue Oct 12, 2015 · 1 comment
Milestone

Comments

@timj
Copy link

timj commented Oct 12, 2015

The cbook.makedirs code does not catch all the problems with multi-threading. We are seeing a very rare failure in the LSST test suite when multiple tests are using matplotlib in parallel. I think it is because the try/catch in makedirs is assuming that only the last part of the path could have the race and only does a single catch around the entire for loop. If both processes are racing to create path A/B/C and both notice that B is missing then the second one to attempt to create B will abort when it finds that B now exists. It should just continue on with trying to make C. I think the try/catch should be in the inner part of the loop around the os.makedirs call.

This is the error we get:

import matplotlib.colorbar
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/contour.py", line 27, in <module>
    import matplotlib.texmanager as texmanager
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/texmanager.py", line 89, in <module>
    class TexManager:
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/texmanager.py", line 124, in TexManager
    mkdirs(texcache)
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/cbook.py", line 1003, in mkdirs
    os.makedirs(thispart, mode)
  File "/home/vagrant/stack/Linux64/anaconda/2.2.0/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '/tmp/matplotlib-vagrant'

with v1.4.3.

Originally filed as an addendum of #2046. @tacaswell requested I file this separately.

See the PR in #5224

@tacaswell tacaswell added this to the next bug fix release (2.0.1) milestone Oct 12, 2015
@timj
Copy link
Author

timj commented Nov 9, 2015

I think this ticket can be closed given that #5224 has been merged.

@mdboom mdboom closed this as completed Nov 9, 2015
@QuLogic QuLogic modified the milestones: v1.5.0, 2.0.1 (next bug fix release) Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants