[Bug]: Calling start() multiple times on a macos timer doesn't stop the previous timer · Issue #29076 · matplotlib/matplotlib · GitHub
Skip to content

[Bug]: Calling start() multiple times on a macos timer doesn't stop the previous timer #29076

Description

@greglucas

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions