Kevin <edwakev@comcast.net> writes:
Hi Patrick,
I'm a couple weeks new to Python, wxPython, Py, wxWindows, etc. and
I've been playing with your PyShell, PyCrust, PyAlaMode, etc. and I
like them a lot.
Great!
Recently, I noticed in Windows Task Manager that they use a high %
CPU when they are in the background (40-50% on my slow K6-2 400MHz
computer). Interestingly, it appears that this is only the case for
scripts which use py\frame.py, since the demo\PyShell.py or
demo\PyCrust.py do not seem to have this problem.
Not so great...
I used Python's "hotshot" profiler and tried to decipher what was
going on. For some reason, it looks like Frame.OnUpdateMenu is
being called a lot:* With a program runtime of 146.189 CPU seconds, Frame.OnUpdateMenu
was called 13662 times totaling 74.733 CPU seconds.I'm not sure why the event would be occurring so often when I'm not
even touching the menu. I commented out the calls to the
wx.EVT_UPDATE_UI hooking function and the background processing
dropped off to 0-3% which is about normal.
Weird. On linux, PyCrust uses a few percentages of CPU, and drops to
zero when it is in the background.
This may be a bug with wxPython (or wxWindows) since your
py\frame.py code looks fairly simple... though I'm not sure what
happens when Frame.OnUpdateMenu calls wx.Window_FindFocus() and the
current focus window is not in py's thread (win32 ::GetFocus()
returns NULL if the current focus window is not attached to the
calling thread).
I don't know either. Robin?
But I don't think FindFocus is causing the wxUpdateUIEvent(s) to
occur, so the problem probably lies elsewhere.my config (Windows XP):
sys.version_info = (2, 3, 1, 'final', 0)
wxVERSION_STRING = '2.4.2.4u'
Hmm. I haven't tried the unicode build on any of my machines.
py\frame.py:
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id: frame.py,v 1.1.2.3 2003/09/25 13:19:28 PKO Exp $"
__revision__ = "$Revision: 1.1.2.3 $"[11:-2]Please forgive me if this should be reported elsewhere; I'm not sure
of the proper protocol, nor of where the bug actually lies (py,
wxPython, wxWindows).
Contacting me was fine. Don't worry about protocol. I've copied this
reply to the wxPython mailing list in hopes that someone will be able
to help.
Thanks for your time.
And thank you for this detailed report. Hopefully we can get this
resolved. Welcome to the world of Python and wxPython. I hope you
stay.
···
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------