FWD: [python-win32] coinitialize problem

G

Gijs Korremans

Hi,

I'm extending a Python application that uses several com objects and threads.
The origional programmer set the main thread to multithreaded by doing this:
* sys.coinit_flags = 0
* import pythoncom
This is nessacary because otherwise a com (MapObjects2 from ESRI) can't run in
a thread, but now I need to use another com object, which is running in a
thread as well. This com object, made by one of our clients, needs to run in a
single threading model. For some reason, these two com object won't work
together in one application. MapObjects2 works when the coini_flags is set to 0 but then the other com object isn't working and the other way around.

I've tried a lot of things to solve this:
1) don't import pythoncom in the main thread
-- set the mapobjects thread with coInitializeEx(COINIT_MULTITHREADED)
-- set the other trhead with CoInitialize()
2) tried the same things but then with initializing coinit in the mainthread
with both models
3) Made a some test programs, but I had always the same problems, except when
I made 2 functions for the 2 com objects, and started them with beginthreadex
(like described on page 626 from Mark Hammonds book Python programming on
win32) and then coinitialize in the functions, but unfortunately, this is not
an option in our main program

Strange enough, we use 2 other comobjects, adotable for mssql and a com object
for sending smses, and these two are always working.

Can anyone help me with a solution? and maybe som examples?

Kind Regards,

Gijs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top