Tk Source Code

View Ticket
Login
Ticket UUID: 2f1086ac088c35931a428127b319d2a02a47dc4c
Title: tkinter.Tk.after() causes freeze when clock shifts into the past
Type: Bug Version: 8.6.16
Submitter: harvie Created on: 2025-04-09 14:27:32
Subsystem: 69. Events Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2025-04-09 19:47:25
Resolution: None Closed By: nobody
    Closed on:
Description:
Hello,
i am using tkinter.Tk.after() in python on Linux to regulary initiate callback event every 300ms, but when clock moves into the past, the .after() never times out again (i assume unless we wait long enough to get back to original date and time). This kind of bugs is usualy solved by using CLOCK_MONOTONIC instead of CLOCK_REALTIME, but i am not really familiar with Tk codebase.
User Comments: chw added on 2025-04-09 19:47:25:
Also see this ticket https://core.tcl-lang.org/tcl/info/3328635fffffffff

Seems that this drowned issue resurfaces every fifth or seventh year.

There's even a TIP#302.

harvie added on 2025-04-09 15:47:08:
Debian 12.10    ARM64
tcl/tk 8.6.13-2 
is also affected

harvie added on 2025-04-09 15:41:54:
ArchLinux x86-64
tcl/tk 8.6.16-1

oehhar added on 2025-04-09 15:31:15:

Harvie, sorry for the bus. I already thought, this was fixed.

Can you please post your TCL/Tk version and exact platform?

Thanks, Harald


harvie (claiming to be Harviecz) added on 2025-04-09 15:06:48:
I am a person who was once stucked in a bus that was waiting for green traffic light for a 1 hour during daylight saving time transition.
And this comment by @kennykb in mentioned ticket infuriates me:

> Alas, there isn't any way to *wait* for a monotonically increasing timer in either Windows or Unix.

There obviously is a way and on Linux it's called CLOCK_MONOTONIC. Industry would be in a great trouble without it, so lets use it please...

oehhar added on 2025-04-09 14:38:04:

Harviecz, thanks for the ticket, I appreciate.

I suppose, this is a TCL bug. The platform details, Tcl and Tk version are probably very important to answer.

Here are some tickets saying, this does not work:

I would also state, that I would be glad, if this could be fixed...

Thanks for all, Harald