Re: Starting a thread before wxPython bootup ... interesting.
- From: "Chris Mellon" <arkanes@xxxxxxxxx>
- Date: Thu, 4 Oct 2007 13:35:09 -0500
On 10/4/07, Shafik <shafik23@xxxxxxxxx> wrote:
Hello folks,
I'm having an issue with mixing wxPython and threading ... I realize
multi-threading always introduces subtle bugs, but the following
scenario is just odd:
I start a dummy thread, that does nothing but increment a counter and
print its value to the screen, then afterwards, I start the wxPython
application. I get nothing but weird behavior: sometimes the gui just
crashes, sometimes I get an exception, sometimes it runs for a little
but very slowly ...
Anyone know whats going on? I have a dual-core T5500, so multi
threading is piece of cake for it hardware -wise.
That's quite a broad and poorly specified problem to ask people to
solve with no code. You get double minus points for mentioning an
exception without saying what it was.
Below is a script that has no demonstrable problems on my machine:
import wx
import threading
if __name__ == '__main__':
run = True
def count():
counter = 0
while run:
print counter
counter += 1
thread = threading.Thread(target=count)
thread.start()
app = wx.App(False)
f = wx.Frame(None)
f.Show()
app.MainLoop()
run = False
Since the counter loop spins tightly, this causes some CPU contention
and could quite possibly cause a non-trivial GUI to respond poorly,
but that's to be expected.
.
- References:
- Prev by Date: Re: using regular express to analyze lisp code
- Next by Date: Re: win32com COMAdminCatalogObject Value method
- Previous by thread: Starting a thread before wxPython bootup ... interesting.
- Next by thread: Re: Starting a thread before wxPython bootup ... interesting.
- Index(es):
Relevant Pages
|