MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _warn_if_gui_out_of_main_thread

Function _warn_if_gui_out_of_main_thread

lib/matplotlib/pyplot.py:550–569  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

548
549
550def _warn_if_gui_out_of_main_thread() -> None:
551 warn = False
552 canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
553 if canvas_class.required_interactive_framework:
554 if hasattr(threading, 'get_native_id'):
555 # This compares native thread ids because even if Python-level
556 # Thread objects match, the underlying OS thread (which is what
557 # really matters) may be different on Python implementations with
558 # green threads.
559 if threading.get_native_id() != threading.main_thread().native_id:
560 warn = True
561 else:
562 # Fall back to Python-level Thread if native IDs are unavailable,
563 # mainly for PyPy.
564 if threading.current_thread() is not threading.main_thread():
565 warn = True
566 if warn:
567 _api.warn_external(
568 "Starting a Matplotlib GUI outside of the main thread will likely "
569 "fail.")
570
571
572# This function's signature is rewritten upon backend-load by switch_backend.

Callers 2

new_figure_managerFunction · 0.85
showFunction · 0.85

Calls 1

_get_backend_modFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…