Skip to content

Commit f6e282b

Browse files
committed
FIX: Event loop timers should only run for the specified time
The implementation of start_event_loop would previously just count the number of sleeps that occurred. But this could lead to longer event loop times if flush_events() added time into the loop. We want the condition to be dependent on the end-time so we don't run our loop longer than necessary.
1 parent 0f6a157 commit f6e282b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,12 +2321,10 @@ def start_event_loop(self, timeout=0):
23212321
if timeout <= 0:
23222322
timeout = np.inf
23232323
timestep = 0.01
2324-
counter = 0
2325-
self._looping = True
2326-
while self._looping and counter * timestep < timeout:
2324+
t_end = time.time() + timeout
2325+
while time.time() < t_end:
23272326
self.flush_events()
23282327
time.sleep(timestep)
2329-
counter += 1
23302328

23312329
def stop_event_loop(self):
23322330
"""

0 commit comments

Comments
 (0)