Skip to content
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

Matplotlib intermittently prints during some operations #476

Open
m-roberts opened this issue Oct 4, 2021 · 1 comment
Open

Matplotlib intermittently prints during some operations #476

m-roberts opened this issue Oct 4, 2021 · 1 comment

Comments

@m-roberts
Copy link
Contributor

m-roberts commented Oct 4, 2021

This seems to be most evident when using the CLI:

pi@pi-top:~ $ pi-top devices hub
Matplotlib is building the font cache; this may take a moment.

Interestingly, this does not appear to be related to our explicit use of matplotlib.

from matplotlib.font_manager import FontManager
f = FontManager()

The creation of this object is what triggers this message - however, it is on a 5s timer.

pi@pi-top:~ $ time !!
time python3 -c "from matplotlib.font_manager import FontManager; f = FontManager()"

real	0m4.416s
user	0m4.273s
sys	0m0.827s

Given that the time that this takes is ~4.5s on a Pi 4 anyway, it seems that this is something that will continue to occur. There is no API for controlling the behaviour of this class.

Source:

# Delay the warning by 5s.
timer = Timer(5, lambda: _log.warning(
    'Matplotlib is building the font cache; this may take a moment.'))
timer.start()
try:
    for fontext in ["afm", "ttf"]:
        for path in [*findSystemFonts(paths, fontext=fontext),
                     *findSystemFonts(fontext=fontext)]:
            try:
                self.addfont(path)
            except OSError as exc:
                _log.info("Failed to open font file %s: %s", path, exc)
            except Exception as exc:
                _log.info("Failed to extract font properties from %s: "
                          "%s", path, exc)
finally:
    timer.cancel()
@m-roberts
Copy link
Contributor Author

One solution for this would be to package up a modified version of this package which has different behaviour (perhaps a longer timer?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant