Skip to content

Delay the fc-list warning by 5 seconds #7532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Delay the fc-list warning by 5 seconds
  • Loading branch information
astrofrog committed Nov 29, 2016
commit 2a90d9519d4d1d9cc3810456e988b6b8c58d639e
10 changes: 8 additions & 2 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,17 @@ def get_fontconfig_fonts(fontext='ttf'):

fontfiles = {}
try:
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
pipe = subprocess.Popen(['fc-list', '--format=%{file}\\n'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = pipe.communicate()[0]
# We emit a warning if the process has not completed after 5 seconds.
# We avoid showing it before since if this takes < 5 seconds, the user
# probably won't notice.
try:
output = pipe.communicate(timeout=5)[0]
except subprocess.TimeoutExpired:
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
output = pipe.communicate()[0]
except (OSError, IOError):
# Calling fc-list did not work, so we'll just return nothing
return fontfiles
Expand Down