[python-win32] Strange order of OnEnter/LeaveScript site methods in application hosting Python active scripting engine
Milan Kaše
milan.kase at gmail.com
Thu May 30 21:33:17 CEST 2013
I tried to take stack dumps (attached bellow) and it seems that the first
pair of calls is coming from CompileInScriptedSection while the second pair
is from ExecInScriptedSection. Do you have a clue what's going on here?
0.00000000 *** OnEnterScript ***
0.00142864 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
0.00142864 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
0.00142864 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
0.00142864 return func(*args)
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 610, in SetScriptState
0.00142864 self.Run()
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 788, in Run
0.00142864 self.ExecutePendingScripts()
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 736, in ExecutePendingScripts
0.00142864 self.DoExecutePendingScripts()
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\pyscript.py",
line 237, in DoExecutePendingScripts
0.00142864 if self.CompileInScriptedSection(codeBlock, "exec"):
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 872, in CompileInScriptedSection
0.00142864 self.BeginScriptedSection()
0.00142864 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 972, in BeginScriptedSection
0.00142864 win32api.OutputDebugString("".join(traceback.format_stack()))
0.00574597 *** OnLeaveScript ***
0.00618566 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
0.00618566 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
0.00618566 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
0.00618566 return func(*args)
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 610, in SetScriptState
0.00618566 self.Run()
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 788, in Run
0.00618566 self.ExecutePendingScripts()
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 736, in ExecutePendingScripts
0.00618566 self.DoExecutePendingScripts()
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\pyscript.py",
line 237, in DoExecutePendingScripts
0.00618566 if self.CompileInScriptedSection(codeBlock, "exec"):
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 880, in CompileInScriptedSection
0.00618566 self.EndScriptedSection()
0.00618566 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 979, in EndScriptedSection
0.00618566 win32api.OutputDebugString("".join(traceback.format_stack()))
0.00675985 *** OnEnterScript ***
0.00718076 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
0.00718076 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
0.00718076 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
0.00718076 return func(*args)
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 610, in SetScriptState
0.00718076 self.Run()
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 788, in Run
0.00718076 self.ExecutePendingScripts()
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 736, in ExecutePendingScripts
0.00718076 self.DoExecutePendingScripts()
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\pyscript.py",
line 238, in DoExecutePendingScripts
0.00718076 self.ExecInScriptedSection(codeBlock, globs)
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 899, in ExecInScriptedSection
0.00718076 self.BeginScriptedSection()
0.00718076 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 972, in BeginScriptedSection
0.00718076 win32api.OutputDebugString("".join(traceback.format_stack()))
3.00900340 *** OnLeaveScript ***
3.00964451 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
3.00964451 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
3.00964451 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
3.00964451 return func(*args)
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 610, in SetScriptState
3.00964451 self.Run()
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 788, in Run
3.00964451 self.ExecutePendingScripts()
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 736, in ExecutePendingScripts
3.00964451 self.DoExecutePendingScripts()
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\pyscript.py",
line 238, in DoExecutePendingScripts
3.00964451 self.ExecInScriptedSection(codeBlock, globs)
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 905, in ExecInScriptedSection
3.00964451 self.EndScriptedSection()
3.00964451 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 979, in EndScriptedSection
3.00964451 win32api.OutputDebugString("".join(traceback.format_stack()))
3.01041079 pythoncom error:
3.01048589 Unexpected exception in gateway method 'SetScriptSite'
3.01056170
3.01062036
3.01094675 Traceback (most recent call last):
3.01094675 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
3.01094675 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
3.01094675 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
3.01094675 return func(*args)
3.01094675 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 580, in SetScriptSite
3.01094675 self.lcid = site.GetLCID()
3.01094675 AttributeError: 'NoneType' object has no attribute 'GetLCID'
3.01102114 pythoncom error:
3.01107931 Unexpected gateway error
3.01122880
3.01147223
3.01194453 Traceback (most recent call last):
3.01194453 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 324, in _InvokeEx_
3.01194453 return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
3.01194453 File "C:\Python27\lib\site-packages\win32com\server\policy.py",
line 585, in _invokeex_
3.01194453 return func(*args)
3.01194453 File
"C:\Python27\lib\site-packages\win32comext\axscript\client\framework.py",
line 580, in SetScriptSite
3.01194453 self.lcid = site.GetLCID()
3.01194453 AttributeError: 'NoneType' object has no attribute 'GetLCID'
2013/5/30 Mark Hammond <skippy.hammond at gmail.com>
> Apart from the engine being called with no script to execute for some
> reason, it may be that an event handler is being added, which causes Python
> to execute things twice - once to "build" the event handler, and again when
> it is actually executed.
>
> Either way, if you check out win32comext/axscript/client/**framework.py
> and look for ApplyInScriptedSection(), you will find where these calls
> originate from. If you can print (or otherwise arrange to see) what the
> code is, it might give us more of a clue.
>
> HTH,
>
> Mark
>
>
> On 30/05/2013 3:34 AM, Milan Kaše wrote:
>
>> Hello,
>> a user of our application which can host various active scripting
>> engines reported problems when using the application together with
>> Python active scripting engine. I traced the problem down to the order
>> in which the engine calls the site's OnEnterScript/OnLeaveScript methods.
>>
>> The usual scenario with other engines (including MS JScript and
>> VBScript) is:
>> 1. OnEnterScript
>> 2. ...executing script...
>> 3. OnLeaveScript
>>
>> However with Python engine, after calling
>> IActiveScript.SetScriptState(**SCRIPTSTATE_CONNECTED) the scenario is
>> following:
>> 1. OnEnterScript
>> 2. OnLeaveScript
>> 3. OnEnterScript
>> 4. ...executing script...
>> 5. OnLeaveScript
>>
>> One would expect either the first scenario or in case the events are
>> raised multiple times, then the calls should be nested (as stated in
>> MSDN, http://msdn.microsoft.com/en-**us/library/9c1cww48(v=vs.94).**aspx<http://msdn.microsoft.com/en-us/library/9c1cww48(v=vs.94).aspx>
>> ).
>> Is the Python's way of calling these methods intentional or is it a bug?
>>
>> Thanks,
>> Milan
>>
>>
>> ______________________________**_________________
>> python-win32 mailing list
>> python-win32 at python.org
>> http://mail.python.org/**mailman/listinfo/python-win32<http://mail.python.org/mailman/listinfo/python-win32>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20130530/4dd4cac8/attachment-0001.html>
More information about the python-win32
mailing list