Open
Description
Bug summary
When calling timer.start(); timer.start()
on an already running timer, the previous timer should be stopped before starting a new one. On the macosx backend this causes two timers to be running under the hood.
Code for reproduction
import time
import matplotlib.pyplot as plt
timer = plt.figure().canvas.new_timer(interval=1000)
timer.add_callback(lambda: print(f"{time.ctime()}"))
timer.start()
timer.start()
plt.pause(2)
Actual outcome
4 prints, 2 per second
Tue Nov 5 09:07:27 2024
Tue Nov 5 09:07:27 2024
Tue Nov 5 09:07:28 2024
Tue Nov 5 09:07:28 2024
Expected outcome
2 prints, 1 per second
Tue Nov 5 09:07:27 2024
Tue Nov 5 09:07:28 2024
Additional information
No response
Operating system
macos
Matplotlib Version
main
Matplotlib Backend
macosx
Python version
No response
Jupyter version
No response
Installation
None