This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Gammaguy, eryksun, josh.r, paul.moore, rhettinger, steve.dower, terry.reedy, tim.golden, vstinner, xtreak, zach.ware
Date 2018-09-03.04:25:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535948745.06.0.56676864532.issue34535@psf.upfronthosting.co.za>
In-reply-to
Content
Another possibility might be to not use the Windows timeout clock, at least not for short timeouts.  The following shows that tk does about 970 1 millesecond timeouts in 1 second (on my machine).
---
import tkinter as tk

root = tk.Tk()
cbid = None
cbcount = 0

def cb():
    global cbid, cbcount
    cbcount += 1
    cbid = root.after(1, cb)

def cbcancel():
    print(cbcount)
    root.after_cancel(cbid)

root.after(1000, cbcancel)
cbid = root.after(1, cb)
root.mainloop()
---

Here is a proof-of-concept queue-get-with-timeout function with sub-millesecond resolution.
---
import tkinter as tk
from queue import Queue, Empty
from time import perf_counter

q = Queue()
fails = 0
value = '<raise Empty>'

def qcb():
    try:
        global value
        value = q.get(block=False)
    except Empty:
        global fails
        fails += 1
        if perf_counter() < stop:
            root.after(0, qcb)
            return
    root.destroy()

def qget_to(timeout):
    global root, stop
    root = tk.Tk()
    root.withdraw()
    stop = perf_counter() + timeout
    qid = root.after(0, qcb)
    #q.put(1)
    root.mainloop()
    print('failures:', fails, 'value:', value)

qget_to(.001)
---

With the put commented out, there are 27 fails (on my machine).  When a value is already available, there are none.  The loop could be parameterized to repeatedly call the no-block version of any similar function.  Large enough time-outs could be partially fulfilled using the system timeout function.
History
Date User Action Args
2018-09-03 04:25:45terry.reedysetrecipients: + terry.reedy, rhettinger, paul.moore, vstinner, tim.golden, zach.ware, eryksun, steve.dower, josh.r, xtreak, Gammaguy
2018-09-03 04:25:45terry.reedysetmessageid: <1535948745.06.0.56676864532.issue34535@psf.upfronthosting.co.za>
2018-09-03 04:25:45terry.reedylinkissue34535 messages
2018-09-03 04:25:44terry.reedycreate