Skip to content

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

Open
@greglucas

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy