()
| 548 | |
| 549 | |
| 550 | def _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. |
no test coverage detected
searching dependent graphs…