[python-win32] wmi + pythonservice : multithreading issues
Mark Hammond
mhammond at skippinet.com.au
Tue Aug 17 11:54:01 CEST 2004
I'm glad other's have responded re WMI, but to you original problem:
> <quote>
> Threading Issues and Accessing WMI Data
>
> To prevent their user interface from being blocked, snap-ins might
> choose to create a background thread for connecting to WMI. Note that
> snap-ins that obtain IWbemServices or IEnumWbemClassObject
> pointers in a
> background thread must marshal it into their main thread or any other
> dialog's thread.
> </quote>
>
> Unfortunately the service framework lauches SvcDoRun in a
> separate thread.
> Has anybody an idea of how to bypass this Microsoft-related
> limitation?
> Or maybe I am completely wrong and I could get the wmi data
> in any thread?
> Or maybe I could hack pythonservice framework to run SvcDoRun in the
> main thread...
Unfortunately, nothing in your quote implies that WMI will not run on
multiple threads - just that you *may* wish to prevent your UI blocking
while the WMI calls execute by using a background thread.
COM threading is subtle though, so if you do follow this route, you should
look for general information on COM threading apartments, and exactly what
"must marshal it into their ... thread" means. Python Programming on Win32
has such a description ;)
Mark
More information about the Python-win32
mailing list