[Patches] [ python-Patches-734118 ] Threaded Python prevents meeting frame rate targets
SourceForge.net
noreply@sourceforge.net
Fri, 09 May 2003 01:20:16 -0700
Patches item #734118, was opened at 2003-05-07 20:45
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=734118&group_id=5470
Category: Tkinter
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Greg Couch (gregcouch)
Assigned to: Nobody/Anonymous (nobody)
Summary: Threaded Python prevents meeting frame rate targets
Initial Comment:
The diffs were made against the CVS version 1.157 of
Python/Modules/_tkinter.c. We are using similar diffs
with Python 2.2.2.
The problem is with the busy-wait interval in
_tkinter.c. Our application wants to output at a 30hz
frame rate, but with a threaded Python, the frame rates
are a multiple of the 20 millisecond Sleep call, so on
a really fast machine either 50hz or 25h (47hz and 23hz
on my system).
Enclosed is a Python test program that demonstrates the
limitation.
If you install a patched version of _tkinter.c, the
program will get the right frame rate.
- Greg Couch
aftertest.py:
------------
#
# Repeatedly register a Tcl "after" callback to see how
many calls
# per second are made with various delay times.
#
start_time = None
count = 0
delay_ms = 33 # milliseconds
def after_cb():
f.after(delay_ms, after_cb)
global count, start_time
import time
t = time.time()
if start_time == None:
start_time = t
count = 0
return
count = count + 1
elapsed_time = float(t - start_time)
if elapsed_time >= 1:
r = count / elapsed_time
print 'After calls per second: %.1f' % r
start_time = t
count = 0
import Tkinter
if hasattr(Tkinter._tkinter, "setbusywaitinterval"):
Tkinter._tkinter.setbusywaitinterval(0)
f = Tkinter.Frame()
f.after(delay_ms, after_cb)
f.mainloop()
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2003-05-09 10:20
Message:
Logged In: YES
user_id=21627
Thanks for the patch. Applied as
NEWS 1.760
_tkinter.c 1.158
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=734118&group_id=5470