473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

high cpu usage in wxPython with Twisted

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:da***@tiger.com.pl
--

_______________________________________________
Python-win32 mailing list
Py**********@python.org
http://mail.python.org/mailman/listinfo/python-win32

Jul 18 '05 #1
1 2481
Try profiling your program with hotshot. At least it should tell you
which functions are sucking up resources.
marchew <da***@tiger.com.pl> wrote in message news:<ma*************************************@pyth on.org>...
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:da***@tiger.com.pl

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jblazi | last post by:
I am having this problem: I use Python for my teaching and right now we are trying to implement some sort of very simple graphical game the pupils can play across the Internet. For this, we use...
2
by: Taki Jeden | last post by:
Hi Anybody used wxPython with twisted? I started putting together a Twisted-based app with wx GUI, and the widgets just don't work - some controls do not show up etc. - at least on my system....
4
by: Brad Tilley | last post by:
When memory usage is a concern, is it better to do: from X import Y or import X Also, is there a way to load and unload modules as they are needed. I have some scripts that sleep for...
2
by: Daniel Bickett | last post by:
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming...
6
by: Zunbeltz Izaola | last post by:
Hi, I have the following problem. I'm developing a GUI program (wxPython). This program has to comunicate (TCP) whit other program that controls a laboratory machine to do a measurement. I...
9
by: perchef | last post by:
Hi, I have several files to download and a GUI to update. I know this is a frequently asked question but i can't find an appropriate solution. My Downloader extends threading.Thread and update a...
1
by: PeterG | last post by:
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic...
6
by: cyberco | last post by:
In my wxPython app a non-GUI thread (that reads info from the network) tries to open a frame to show the new info. This results in my app hanging (which is not too surprising). Coming from a C#...
12
by: bullockbefriending bard | last post by:
I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.