Threading problem in Linux but not windows

Paul Probert said:
Gordon,
    I don't know anything about Boa, but it looks like you want to create a
popup window in your thread?

···

---------

Hi,

Actually, that is the main thread and it is the initialization of the
wxPython wx.App (has nothing to do with boa). The constructor is
__init__(self, redirect=False, filename=None, useBestVisual=False,
clearSigInt=True)

where redirect sends any sys.stdout and sys.stderr to a popup window. I was
setting redirect = True on Windows and a popup box would show any print
statements without problems (actually 2 popup boxes come up so maybe that is
not 100% OK but there is no exception thrown). On Linux there *is* an
exception thrown but no traceback as I said in the original message leaving
me in the dark. Paul's function helped that.

The root of the problem is that there is a print statement in the subthread
that was causing the exception. Because there was no traceback I thought
that the problem was with opening the serial port or file to write to. It
was only what I thought was a benign print statement that was causing all
this grief.

If I set redirect = False then all output goes to the console and things
work as I expect.

As I mentioned in an earlier message the default for redirect is different
for Linux (False) from what it is for Windows/Mac (True). I guess there
must be some reason for it :frowning:

Thanks for all your help.

Regards,

Gordon Williams

Gordon Williams wrote:
...

Actually, that is the main thread and it is the initialization of the
wxPython wx.App (has nothing to do with boa). The constructor is

...
Ah, but there's something fishy here. Could it be that if you redirect stdout and stderr to some other thing (a python function that calls into wxPython) in your main thread, and then launch a new thread, then those "file handles" or whatever they're called are duplicated to be the stdout and stderr of the new thread. Then when the thread writes to them all hell will break loose.
If so, then people should be warned "no threads when you've redirected!"

__init__(self, redirect=False, filename=None, useBestVisual=False,
clearSigInt=True)

where redirect sends any sys.stdout and sys.stderr to a popup window. I was
setting redirect = True on Windows and a popup box would show any print
statements without problems (actually 2 popup boxes come up so maybe that is
not 100% OK but there is no exception thrown). On Linux there *is* an
exception thrown but no traceback as I said in the original message leaving
me in the dark. Paul's function helped that.

...

Paul Probert