Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: add timeouts to font_manager + threading test #28196

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

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
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
11 changes: 9 additions & 2 deletions lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,16 @@ def _test_threading():
from matplotlib.ft2font import LOAD_NO_HINTING
import matplotlib.font_manager as fm

def loud_excepthook(args):
raise RuntimeError("error in thread!")

threading.excepthook = loud_excepthook

N = 10
b = threading.Barrier(N)

def bad_idea(n):
b.wait()
b.wait(timeout=5)
for j in range(100):
font = fm.get_font(fm.findfont("DejaVu Sans"))
font.set_text(str(n), 0.0, flags=LOAD_NO_HINTING)
Expand All @@ -271,7 +276,9 @@ def bad_idea(n):
t.start()

for t in threads:
t.join()
t.join(timeout=9)
if t.is_alive():
raise RuntimeError("thread failed to join")


def test_fontcache_thread_safe():
Expand Down