Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56a932c

Browse filesBrowse files
jenshnielsentacaswell
authored andcommitted
Merge pull request #5276 from mdboom/lockfile
Use lock directory to prevent race conditions Conflicts: lib/matplotlib/font_manager.py
1 parent 673f6c5 commit 56a932c
Copy full SHA for 56a932c

File tree

Expand file treeCollapse file tree

5 files changed

+108
-11
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+108
-11
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ script:
116116
# Travis VM to run out of memory (since so many copies of inkscape and
117117
# ghostscript are running at the same time).
118118
- echo Testing using $NPROC processes
119-
# Generate the font caches in a single process before starting the
120-
# multiple processes
121-
- python -c "from matplotlib import font_manager"
122119
- |
123120
if [[ $BUILD_DOCS == false ]]; then
124121
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples

‎LICENSE/LICENSE_CONDA

Copy file name to clipboard
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Except where noted below, conda is released under the following terms:
2+
3+
(c) 2012 Continuum Analytics, Inc. / http://continuum.io
4+
All Rights Reserved
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Continuum Analytics, Inc. nor the
14+
names of its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL CONTINUUM ANALYTICS BE LIABLE FOR ANY
21+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+
Exceptions
30+
==========
31+
32+
versioneer.py is Public Domain
33+
34+
The ProgressBar package is released under the following terms:
35+
36+
# progressbar - Text progress bar library for Python.
37+
# Copyright (c) 2005 Nilton Volpato
38+
#
39+
# This library is free software; you can redistribute it and/or
40+
# modify it under the terms of the GNU Lesser General Public
41+
# License as published by the Free Software Foundation; either
42+
# version 2.1 of the License, or (at your option) any later version.
43+
#
44+
# This library is distributed in the hope that it will be useful,
45+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47+
# Lesser General Public License for more details.
48+
#
49+
# You should have received a copy of the GNU Lesser General Public
50+
# License along with this library; if not, write to the Free Software
51+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,3 +2553,54 @@ def get_label(y, default_name):
25532553
else:
25542554
def _putmask(a, mask, values):
25552555
return np.copyto(a, values, where=mask)
2556+
2557+
2558+
class Locked(object):
2559+
"""
2560+
Context manager to handle locks.
2561+
2562+
Based on code from conda.
2563+
2564+
(c) 2012-2013 Continuum Analytics, Inc. / http://continuum.io
2565+
All Rights Reserved
2566+
2567+
conda is distributed under the terms of the BSD 3-clause license.
2568+
Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.
2569+
"""
2570+
def __init__(self, path):
2571+
LOCKFN = '.matplotlib_lock'
2572+
self.path = path
2573+
self.end = "-" + str(os.getpid())
2574+
self.lock_path = os.path.join(self.path, LOCKFN + self.end)
2575+
self.pattern = os.path.join(self.path, LOCKFN + '-*')
2576+
self.remove = True
2577+
2578+
def __enter__(self):
2579+
retries = 10
2580+
sleeptime = 1
2581+
while retries:
2582+
files = glob.glob(self.pattern)
2583+
if files and not files[0].endswith(self.end):
2584+
time.sleep(sleeptime)
2585+
sleeptime *= 2
2586+
retries -= 1
2587+
else:
2588+
break
2589+
else:
2590+
raise RuntimeError(lockstr)
2591+
2592+
if not files:
2593+
try:
2594+
os.makedirs(self.lock_path)
2595+
except OSError:
2596+
pass
2597+
else: # PID lock already here --- someone else will remove it.
2598+
self.remove = False
2599+
2600+
def __exit__(self, exc_type, exc_value, traceback):
2601+
if self.remove:
2602+
for path in self.lock_path, self.path:
2603+
try:
2604+
os.rmdir(path)
2605+
except OSError:
2606+
pass

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,14 @@ def findfont(prop, fontext='ttf'):
14121412

14131413
def _rebuild():
14141414
global fontManager
1415+
14151416
fontManager = FontManager()
1417+
14161418
if _fmcache:
1417-
pickle_dump(fontManager, _fmcache)
1419+
with cbook.Locked(cachedir):
1420+
pickle_dump(fontManager, _fmcache)
1421+
1422+
14181423
verbose.report("generated new fontManager")
14191424

14201425
if _fmcache:

‎tests.py

Copy file name to clipboardExpand all lines: tests.py
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
from matplotlib.testing.noseclasses import KnownFailure
2222
from matplotlib import default_test_modules
2323

24-
from matplotlib import font_manager
25-
# Make sure the font caches are created before starting any possibly
26-
# parallel tests
27-
if font_manager._fmcache is not None:
28-
while not os.path.exists(font_manager._fmcache):
29-
time.sleep(0.5)
30-
3124
plugins = [KnownFailure, attrib.Plugin]
3225

3326
# Nose doesn't automatically instantiate all of the plugins in the

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.