Re: Starting a thread before wxPython bootup ... interesting.



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.
.



Relevant Pages

  • Starting a thread before wxPython bootup ... interesting.
    ... I'm having an issue with mixing wxPython and threading ... ... scenario is just odd: ...
    (comp.lang.python)
  • ReaderWriterLock with low timeout throws unhandled exception
    ... I am working on improving my threading skills and came across a question. ... When working with the ReaderWriterLock class, ... The logic answer I can think of is, that if one specifies a timeout, then ... the CLR respects that and throws an exception regardless of what's inside ...
    (microsoft.public.dotnet.languages.csharp)
  • Logging and threading
    ... I'm having some problems getting the logging module to work with the ... threading module. ... I/O operation on closed file ... The exception isn't fatal though, as the print "finished" line is ...
    (comp.lang.python)
  • Re: Web Services Client Error
    ... to be unable to catch a .NET exception. ... The only complication which has just come to mind is threading - am I ... correct in assuming that by wrapping the whole program in a block like ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: DTS from C#
    ... From a console application, WinForms, ASP.NET? ... > What threading option are you using? ... whatever the default in C# code is - as an ex-VB head ... Yes I am catching the COM exception explicity. ...
    (microsoft.public.sqlserver.dts)