FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fall back to Python-level Thread for GUI warning by QuLogic · Pull Request #24178 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 15 additions & 5 deletions lib/matplotlib/pyplot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,21 @@ def draw_if_interactive():


def _warn_if_gui_out_of_main_thread():
# This compares native thread ids because even if python-level Thread
# objects match, the underlying OS thread (which is what really matters)
# may be different on Python implementations with green threads.
if (_get_required_interactive_framework(_get_backend_mod()) and
threading.get_native_id() != threading.main_thread().native_id):
warn = False
if _get_required_interactive_framework(_get_backend_mod()):
if hasattr(threading, 'get_native_id'):
# This compares native thread ids because even if Python-level
# Thread objects match, the underlying OS thread (which is what
# really matters) may be different on Python implementations with
# green threads.
if threading.get_native_id() != threading.main_thread().native_id:
warn = True
else:
# Fall back to Python-level Thread if native IDs are unavailable,
# mainly for PyPy.
if threading.current_thread() is not threading.main_thread():
warn = True
if warn:
_api.warn_external(
"Starting a Matplotlib GUI outside of the main thread will likely "
"fail.")
Expand Down

Back | FazBrowse Home | New Git URL