Bugs item #3008512, was opened at 2010-05-28 14:30
Message generated for change (Tracker Item Submitted) made by kahlbutz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3008512&group_id=78018
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: com
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Klaus Noekel (kahlbutz)
Assigned to: Nobody/Anonymous (nobody)
Summary: COM server built with pythoncom crashes on second call
Initial Comment:
I am experiencing crashes with Python-based COM servers, if their methods use wxPython. I post the problem to this buglist, because I am not sure whether the effect is caused by wxPython or pywin32. Here is what happens:
My COM server is a slight variation of the small example from ch. 12 of Mark's book:
import wx
class PythonUtilities:
_public_methods_ = [ 'SplitString' ]
_reg_progid_ = "PythonAddIn.Runner"
# NEVER copy the following ID
# Use "print pythoncom.CreateGuid()" to make a new one.
_reg_clsid_ = "{91D9FEF4-B762-43AF-A0A5-965DA7B6A8EB}"
def SplitString(self, val, item=None):
import string
app = wx.PySimpleApp(0)
if item != None: item = str(item)
res = string.split(str(val), item)
for i,x in enumerate(res):
wx.MessageBox(str(x),str(i))
return res
# Add code so that when this script is run by
# Python.exe, it self-registers.
if __name__ == '__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtilities)
No, it does not do anything useful, but I managed to scale back the original example to this toy. Note that the method displays a few strings in a wx.MessageBox. Any call to wx causes the behavior described below.
Here is a VBA client for the server:
Sub COMTest()
Set Runner = CreateObject("PythonAddIn.Runner")
x = Runner.SplitString("fgh;jh;oei", ";")
Set Runner = Nothing
End Sub
Can't be much simpler than that. The first run of this client from Excel always succeeds, and three MessageBoxes pop up, as you would expect. The behavior on the second run (from the same Excel session) depends on the OS version running. Under Win 7 64-bit the second (and all subsequent) runs work just fine. Under XP SP2 32-bit the second run always crashes Excel. On OS's in between these two the second run may or may not crash, sometimes it even depends on the machine.
Versions used: Python 2.5.4, pywin32 -212, wxPython 2.8.9.1. The Excel version is unimportant, the crashes occur even in clients written in C++.
Any clue? I'd appreciate any advice!
Thanks,
Klaus Noekel
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3008512&group_id=78018
|