Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9bcdd60

Browse files
authored
Merge pull request#24178 from QuLogic/pypy-threads
Fall back to Python-level Thread for GUI warning
2 parents8be23b6 +d4cf0f7 commit9bcdd60

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎lib/matplotlib/pyplot.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,21 @@ def draw_if_interactive():
332332

333333

334334
def_warn_if_gui_out_of_main_thread():
335-
# This compares native thread ids because even if python-level Thread
336-
# objects match, the underlying OS thread (which is what really matters)
337-
# may be different on Python implementations with green threads.
338-
if (_get_required_interactive_framework(_get_backend_mod())and
339-
threading.get_native_id()!=threading.main_thread().native_id):
335+
warn=False
336+
if_get_required_interactive_framework(_get_backend_mod()):
337+
ifhasattr(threading,'get_native_id'):
338+
# This compares native thread ids because even if Python-level
339+
# Thread objects match, the underlying OS thread (which is what
340+
# really matters) may be different on Python implementations with
341+
# green threads.
342+
ifthreading.get_native_id()!=threading.main_thread().native_id:
343+
warn=True
344+
else:
345+
# Fall back to Python-level Thread if native IDs are unavailable,
346+
# mainly for PyPy.
347+
ifthreading.current_thread()isnotthreading.main_thread():
348+
warn=True
349+
ifwarn:
340350
_api.warn_external(
341351
"Starting a Matplotlib GUI outside of the main thread will likely "
342352
"fail.")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp