a strange problem in python multi-thread programming

W

WU FUHENG

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?
 
D

Diez B. Roggisch

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?
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top