开发者

Python binary executable with MSAA hangs on exit

I'm using python comtypes to get access to IAccessible interface for MSAA (Microsoft Active Accessibility) usage. After that we create binary executable using pyinstaller, so the problem is that on specific platform - Windows XP x64 our executable hangs on exit. It hangs on WaitFotMultipleObjectsEx in ole32.dll after the process exit point is called - it hangs in system code not in our, or even pyinstaller boot loader. During investigation we located the problem - it is in creating many IAccessible objects (i.e. creating child tree) - if you do it proccess hangs. Wanna know if somebody else faced sim开发者_开发知识库ilar problem?

P.S. On other OSes it works fine.


I'm not able to clearly understood the root reason of this issue currently. But the solution was found, even two.

First: to add an additional call to CoUninitialize function. Don't know why it works as the comtypes calls CoUninitialize the same times as CoInitialize.

Second: to change CoInitializeEx flags, cause if COINIT_APARTMENTTHREADED is set (it is default value in comtypes if sys.coinit_flags is not defined) - process hangs! So i've choosen COINIT_SPEED_OVER_MEMORY and everything became fine! The easiest way to set it is to do following before importing comtypes:

import sys
sys.coinit_flags = 0x8 # COINIT_SPEED_OVER_MEMORY == 0x8
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜