Skip to content

Commit 5095a33

Browse files
committed
Ignore threading errors when preparing font cache
In Enscripten/WASM, this module can be imported, but doesn't work, so we can't fall back to `dummy_threading` at import-time as we used to do.
1 parent 8eceb82 commit 5095a33

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/font_manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,12 @@ def __init__(self, size=None, weight='normal'):
10861086
self.ttflist = []
10871087

10881088
# Delay the warning by 5s.
1089-
timer = threading.Timer(5, lambda: _log.warning(
1090-
'Matplotlib is building the font cache; this may take a moment.'))
1091-
timer.start()
1089+
try:
1090+
timer = threading.Timer(5, lambda: _log.warning(
1091+
'Matplotlib is building the font cache; this may take a moment.'))
1092+
timer.start()
1093+
except RuntimeError:
1094+
timer = None
10921095
try:
10931096
for fontext in ["afm", "ttf"]:
10941097
for path in [*findSystemFonts(paths, fontext=fontext),
@@ -1101,7 +1104,8 @@ def __init__(self, size=None, weight='normal'):
11011104
_log.info("Failed to extract font properties from %s: "
11021105
"%s", path, exc)
11031106
finally:
1104-
timer.cancel()
1107+
if timer:
1108+
timer.cancel()
11051109

11061110
def addfont(self, path):
11071111
"""

0 commit comments

Comments
 (0)