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

Skip to content

Compare thread native ids when checking whether running on main thread. #23445

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
Jul 20, 2022
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
7 changes: 5 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,11 @@ def draw_if_interactive():


def _warn_if_gui_out_of_main_thread():
if (_get_required_interactive_framework(_get_backend_mod())
and threading.current_thread() is not threading.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):
_api.warn_external(
"Starting a Matplotlib GUI outside of the main thread will likely "
"fail.")
Expand Down