Skip to content

Commit 113e581

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 bdbf1ee commit 113e581

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
@@ -1090,9 +1090,12 @@ def __init__(self, size=None, weight='normal'):
10901090
self.ttflist = []
10911091

10921092
# Delay the warning by 5s.
1093-
timer = threading.Timer(5, lambda: _log.warning(
1094-
'Matplotlib is building the font cache; this may take a moment.'))
1095-
timer.start()
1093+
try:
1094+
timer = threading.Timer(5, lambda: _log.warning(
1095+
'Matplotlib is building the font cache; this may take a moment.'))
1096+
timer.start()
1097+
except RuntimeError:
1098+
timer = None
10961099
try:
10971100
for fontext in ["afm", "ttf"]:
10981101
for path in [*findSystemFonts(paths, fontext=fontext),
@@ -1105,7 +1108,8 @@ def __init__(self, size=None, weight='normal'):
11051108
_log.info("Failed to extract font properties from %s: "
11061109
"%s", path, exc)
11071110
finally:
1108-
timer.cancel()
1111+
if timer:
1112+
timer.cancel()
11091113

11101114
def addfont(self, path):
11111115
"""

0 commit comments

Comments
 (0)