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

a strange problem in python multi-thread programming

P: n/a
Today,I found a strange problem in python multi-thread programming.When I used function win32com.client.Dispatch('ADODB.Connection') in primary thread, it was OK. But when I called it in secondary-thread, it raised a exception. Then debugging and tracking the code, I found the problem was from the function pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) in . The parameters are (ADODB.Connection, None, 21, {00020400-0000-0000-C000-000000000046}). But just as I said above, this function would be ok in primaray thread mode but not work in the secondary-thread mode. Since this function is from the dll(in my computer is python23.dll), I can not see the source code and don't know how to solve this problem. Anyone can help me?
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> Today,I found a strange problem in python multi-thread programming.When I
used function win32com.client.Dispatch('ADODB.Connection') in primary
thread, it was OK. But when I called it in secondary-thread, it raised a
exception. Then debugging and tracking the code, I found the problem was
from the function pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch) in . The parameters are (ADODB.Connection, None,
21, {00020400-0000-0000-C000-000000000046}). But just as I said above,
this function would be ok in primaray thread mode but not work in the
secondary-thread mode. Since this function is from the dll(in my computer
is python23.dll), I can not see the source code and don't know how to
solve this problem. Anyone can help me?


It has been years since I dealed with COM the last time - so I'm sort of on
the speculative side here. However I remember that there were different
com-server-models your com-objects could support. They dealt with
in/out-processes and threading. So might it be that your ADODB.Connection
is not supposed to be called in a multi-threaded environment?

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.