Skip to content

Timer + long-running callback expectations #29029

@greglucas

Description

@greglucas

Do we want to say anything about how we expect our event timers to behave with regard to when they fire? Should a timer be ticking continuously and firing when requested regardless of other tasks occurring (maybe in a separate thread), or should the timers fire at (time in callback + interval)?

Following up with some results about what the various backends currently do for callbacks that last longer than the timers with the following test script that will either print ~1/second or every 2-seconds.

import time
import matplotlib.pyplot as plt

fig = plt.figure()

def on_timer():
    print(time.ctime())
    time.sleep(1)

timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(on_timer)
timer.start()
fig.canvas.start_event_loop(10)

macos: 2-seconds
tkagg: 2-seconds
qtagg: 1-second
gtk4agg: 1-second
wxagg: 2-seconds

So I can't say we have a standard right now, or if we should even try to set an expectation of one or the other cases to make things consistent.

Originally posted by @greglucas in #29023 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    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