Hi folks,
Peter Hanson, on the wxPython list, seems to have identified a bug in
the gestalt module, that may be a Carbon issue. It's a bit of an unusual
case: it freezes up wxPython, when wx is called from other than the main
thread. Robin Dunn suspects that it's a Carbon issue -- gestalt is
calling Carbon, and doing so in the main thread, so you are then trying
to call Carbon from more than one thread, which may be the cause of the
problem. I've confirmed that if you call gestalt from the same thread as
wxPython, there is no failure.
A link to Robin Dunn's assessment:
http://permalink.gmane.org/gmane.comp.python.wxpython/76590
As Carbon is deprecated anyway, I guess it's time for gestalt ( or
platform.mac_ver ) to be re-written
I've tested on OS-X 10.4.11, Python 2.5 and Python2.6
Here is Peter's summary and sample code:
# Demonstration of application freeze on OSX.
# Running "python osx_freeze.py" shows the symptom:
# non-responsiveness after about 3 seconds. In theory
# this will occur in any wxPython app which runs
# the GUI event loop in a thread other than the one
# in which the failing gestalt('sysu') call (see below)
# is first executed.
# Enabling any of these imports can trigger the problem
# as each one imports the next one down in the list.
# This will happen only with pkg_resources v0.6c10 or later
# although it's not pkg_resources' fault.
# import matplotlib.figure
# import matplotlib.axes
# import matplotlib.dates
# import pytz
# import pkg_resources
# The next import alone doesn't lead to failure,
# but the function call does.
# This same code is executed by pkg_resources starting
# with setuptools v0.6c10.
# from platform import mac_ver; mac_ver()
# The platform.mac_ver() call does the following, which
# is what ultimately leads to the failure. Calls
# to gestalt() with 'sysa' (for example) do not
# trigger the problem, either because the problem is
# related to the 'sysu' itself, or to the fact that
# an exception is raised because the selector "sysu"
# is no longer recognized.
from gestalt import gestalt
try:
print gestalt('sysu')
except Exception, ex:
print 'gestalt call failed'
if __name__ == '__main__':
def gui():
import wx
app = wx.App(False)
frame = wx.Frame(None)
wx.StaticText(frame, label='Goodbye, cruel world')
frame.Show()
app.MainLoop()
import threading
threading.Thread(target=gui).start()
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
chris.bar...@noaa.gov
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig