🌐 AI搜索 & 代理 主页
Skip to content

Commit ef900b6

Browse files
appease CI
1 parent b2babcb commit ef900b6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,25 @@ def check_alt_backend(alt_backend):
147147
# not resize incorrectly.
148148
assert_equal(result.getvalue(), result_after.getvalue())
149149
150-
# Test artists and drawing from thread does not crash (no other guarantees)
150+
# Test artists and drawing does not crash from thread (no other guarantees)
151151
fig, ax = plt.subplots()
152152
# plt.pause needed vs plt.show(block=False) at least on toolbar2-tkagg
153-
plt.pause(0.5)
153+
plt.pause(0.1)
154154
155155
exc_info = None
156156
157157
def thread_artist_work():
158158
try:
159159
ax.plot([1,3,6])
160-
except Exception as e:
160+
except:
161161
# Propagate error to main thread
162162
global exc_info
163163
exc_info = sys.exc_info()
164164
165165
def thread_draw_work():
166166
try:
167167
fig.canvas.draw()
168-
except Exception as e:
168+
except:
169169
# Propagate error to main thread
170170
global exc_info
171171
exc_info = sys.exc_info()
@@ -175,19 +175,18 @@ def thread_draw_work():
175175
# artists never wait for the event loop to run, so just join
176176
t.join()
177177
178-
if exc_info is not None: # Raise thread error
178+
if exc_info: # Raise thread error
179179
raise exc_info[1].with_traceback(exc_info[2])
180180
181181
t = threading.Thread(target=thread_draw_work)
182-
timer = fig.canvas.new_timer(1.)
183-
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
184-
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
185182
fig.canvas.mpl_connect("close_event", print)
186183
t.start()
187-
fig.canvas.start_event_loop()
184+
plt.pause(0.1) # flush_events fails on at least Tkagg (bpo-41176)
188185
t.join()
186+
plt.close()
187+
fig.canvas.flush_events() # pause doesn't process events after close
189188
190-
if exc_info is not None: # Raise thread error
189+
if exc_info: # Raise thread error
191190
raise exc_info[1].with_traceback(exc_info[2])
192191
"""
193192
_test_timeout = 10 # Empirically, 1s is not enough on Travis.

0 commit comments

Comments
 (0)