a strange problem in python multi-thread programming

Diez B. Roggisch nospam-deets at web.de
Thu Feb 5 06:58:42 EST 2004


> 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



More information about the Python-list mailing list