high cpu usage in wxPython with Twisted

M

marchew

hi,

i have a problem integrating wxPython and Twisted under Win32. my
application consumes 40-50% of CPU resources when wxFrame is visible and reactor
(twisted) is running. i looked at integration example which comes with twisted
package and figured that it also has that problem. here comes listing:

PYTHON_HOME\Lib\site-packages\TwistedDocs\examples\wxdemo.py

#----------------------------------------------------------------
from wxPython.wx import *

from twisted.internet import wxreactor
wxreactor.install()
from twisted.internet import reactor


# set up so that "hello, world" is printed once a second
def helloWorld():
print "hello, world"
reactor.callLater(1, helloWorld)
reactor.callLater(1, helloWorld)

def twoSecondsPassed():
print "two seconds passed"

reactor.callLater(2, twoSecondsPassed)

ID_EXIT = 101

class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(300, 200))
menu = wxMenu()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
EVT_MENU(self, ID_EXIT, self.DoExit)

def DoExit(self, event):
self.Close(true)
reactor.stop()

class MyApp(wxApp):

def OnInit(self):
frame = MyFrame(NULL, -1, "Hello, world")
frame.Show(true)
self.SetTopWindow(frame)
return true


def demo():
app = MyApp(0)
reactor.registerWxApp(app)
reactor.run(0)


if __name__ == '__main__':
demo()
#----------------------------------------------------------------

can You help me? has anyone encountered similar problem?

--
marchew mailto:[email protected]
--

_______________________________________________
Python-win32 mailing list
(e-mail address removed)
http://mail.python.org/mailman/listinfo/python-win32
 
L

Lonnie Princehouse

Try profiling your program with hotshot. At least it should tell you
which functions are sucking up resources.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top