8000 Merge pull request #6777 from mdboom/fix-font-cache-rebuild-timeout · matplotlib/matplotlib@e691c28 · GitHub
[go: up one dir, main page]

Skip to content

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 e691c28

Browse files
committed
Merge pull request #6777 from mdboom/fix-font-cache-rebuild-timeout
Raise lock timeout as actual exception
1 parent c4b2256 commit e691c28

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/matplotlib/cbook.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,10 +2687,11 @@ def _putmask(a, mask, values):
26872687
return np.copyto(a, values, where=mask)
26882688

26892689
_lockstr = """\
2690-
LOCKERROR: matplotlib is trying to acquire the lock {!r}
2690+
LOCKERROR: matplotlib is trying to acquire the lock
2691+
{!r}
26912692
and has failed. This maybe due to any other process holding this
2692-
lock. If you are sure no other matplotlib process in running try
2693-
removing this folder(s) and trying again.
2693+
lock. If you are sure no other matplotlib process is running try
2694+
removing these folders and trying again.
26942695
"""
26952696

26962697

@@ -2708,6 +2709,9 @@ class Locked(object):
27082709
"""
27092710
LOCKFN = '.matplotlib_lock'
27102711

2712+
class TimeoutError(RuntimeError):
2713+
pass
2714+
27112715
def __init__(self, path):
27122716
self.path = path
27132717
self.end = "-" + str(os.getpid())
@@ -2717,18 +2721,17 @@ def __init__(self, path):
27172721

27182722
def __enter__(self):
27192723
retries = 50
2720-
sleeptime = 1
2724+
sleeptime = 0.1
27212725
while retries:
27222726
files = glob.glob(self.pattern)
27232727
if files and not files[0].endswith(self.end):
27242728
time.sleep(sleeptime)
2725-
sleeptime *= 1.1
27262729
retries -= 1
27272730
else:
27282731
break
27292732
else:
27302733
err_str = _lockstr.format(self.pattern)
2731-
raise RuntimeError(err_str)
2734+
raise self.TimeoutError(err_str)
27322735

27332736
if not files:
27342737
try:

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,8 @@ def _rebuild():
14341434
else:
14351435
fontManager.default_size = None
14361436
verbose.report("Using fontManager instance from %s" % _fmcache)
1437+
except cbook.Locked.TimeoutError:
1438+
raise
14371439
except:
14381440
_rebuild()
14391441
else:

0 commit comments

Comments
 (0)
0