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

Skip to content

Commit 5673e33

Browse files
authored
Merge pull request #28196 from tacaswell/tst/add_timeouts
TST: add timeouts to font_manager + threading test
2 parents d4f0963 + 680b957 commit 5673e33

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/matplotlib/tests/test_font_manager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,16 @@ def _test_threading():
253253
from matplotlib.ft2font import LOAD_NO_HINTING
254254
import matplotlib.font_manager as fm
255255

256+
def loud_excepthook(args):
257+
raise RuntimeError("error in thread!")
258+
259+
threading.excepthook = loud_excepthook
260+
256261
N = 10
257262
b = threading.Barrier(N)
258263

259264
def bad_idea(n):
260-
b.wait()
265+
b.wait(timeout=5)
261266
for j in range(100):
262267
font = fm.get_font(fm.findfont("DejaVu Sans"))
263268
font.set_text(str(n), 0.0, flags=LOAD_NO_HINTING)
@@ -271,7 +276,9 @@ def bad_idea(n):
271276
t.start()
272277

273278
for t in threads:
274-
t.join()
279+
t.join(timeout=9)
280+
if t.is_alive():
281+
raise RuntimeError("thread failed to join")
275282

276283

277284
def test_fontcache_thread_safe():

0 commit comments

Comments
 (0)