Skip to content

Commit 4f1ca3f

Browse files
committed
Delay the fc-list warning by 5 seconds
1 parent b9c3b64 commit 4f1ca3f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/font_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,17 @@ def get_fontconfig_fonts(fontext='ttf'):
273273

274274
fontfiles = {}
275275
try:
276-
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
277276
pipe = subprocess.Popen(['fc-list', '--format=%{file}\\n'],
278277
stdout=subprocess.PIPE,
279278
stderr=subprocess.PIPE)
280-
output = pipe.communicate()[0]
279+
# We emit a warning if the process has not completed after 5 seconds.
280+
# We avoid showing it before since if this takes < 5 seconds, the user
281+
# probably won't notice.
282+
try:
283+
output = pipe.communicate(timeout=5)[0]
284+
except subprocess.Timeout:
285+
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
286+
output = pipe.communicate()[0]
281287
except (OSError, IOError):
282288
# Calling fc-list did not work, so we'll just return nothing
283289
return fontfiles

0 commit comments

Comments
 (0)