By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

FWD: [python-win32] coinitialize problem

P: n/a

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 runin
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

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and is
believed to be clean.
http://www.networksentry.co.za

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.