Question

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 similar problem?

P.S. On other OSes it works fine.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top