[Pythonmac-SIG] Threaded GUI application....

Tim Ansell mithro at mithis.com
Sun Jan 28 07:07:30 CET 2007


Hello,

I currently have a threaded GUI application. I have a "GUI" thread
(which is always the main thread), a "Media Download" thread, and a few
other misc threads. 

Everything worked fine on Mac OS X until I added the "Media Download"
thread. I was very careful to make sure GUI calls only occured in the
GUI thread (because otherwise you get "Bus Error" segfaults).

However, after I added the "Media Download" thread, I started getting
"Bus Error". I couldn't figure out why for a long time, the "Media
Download" thread definitely makes no GUI calls in any of my code. 

I trace the error to urlib.py in the standard library. The culprit is
the following lines,

----
if sys.platform == 'darwin':
    def getproxies_internetconfig():
        """Return a dictionary of scheme -> proxy server URL mappings.

        By convention the mac uses Internet Config to store
        proxies.  An HTTP proxy, for instance, is stored under
        the HttpProxy key.

        """
        try:
            import ic
        except ImportError:
            return {}
-------

It dies on the "import ic" line with a "Bus Error". I'm assuming this is
because the IC module interacts with the GUI, and as it isn't the main
thread causes this problem.

So, my question is, how do I get around/fix this?

Is there a way to "catch" the Bus Error and just throw an exception? Can
I override the getproxies_internetconfig function?

Are there any other standard library functions I should avoid calling in
a non-main thread under Mac?

Thanks for your help.

Tim Ansell



More information about the Pythonmac-SIG mailing list