How do I avoid the Tkinter 30 msec polling loop.
Paul Jackson
pj at sgi.com
Fri Mar 16 14:09:06 EST 2001
I have a little 'biff' (BSD-speak for email watchdog) like
program, written in Python, using Tkinter, that shows one of
two text messages in a little window, depending on whether my
email box has new mail in it. The app polls the mailbox every
minute, with an os.stat() call.
Unfortunately, the app consumes cpu almost continuously,
even when I wish it would sleep for the minute.
The same busy loop can be see even on the smallest "Hello,
world" example, such as:
import Tkinter
root = Tkinter.Tk()
label = Tkinter.Label(root, text = "Hello, world.")
label.pack()
root.mainloop()
A system call trace of the above, on Irix 6.5.11, using
Python 2.1a1 (#23, Feb 2 2001, 17:25:50) [C] on irix6,
shows the following 2 select() system calls, every 30 msec,
non-stop:
hello.py( 3693): select(4, [3], [<empty>], [<empty>], {sec=0, usec=0})
hello.py( 3693): select(0, 0, 0, 0, {sec=0, usec=20000})
This is on a system with a 10 msec TICK, and a timeout on
the select of 20 msec, which ends up taking 30 msec each
loop (timeouts are rounded up to the next TICK).
===
Anyhow, is there anyway to stop or radically slow this loop?
The little window responds to no key or mouse input. It just
changes the text message when Label.configure (text="you have
mail") or some such is executed after the once a minute thread
wakes up and notices a change in the mail box.
I won't rest till it's the best ...
Manager, Linux System Software
Paul Jackson <pj at sgi.com> 1.650.933.1373
--
I won't rest till it's the best ...
Manager, Linux System Software
Paul Jackson <pj at sgi.com> 1.650.933.1373
More information about the Python-list
mailing list