Today,I found a strange problem in python multi-thread programming.Whe n I used function win32com.client .Dispatch('ADOD B.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.CoCre ateInstance(IDi spatch, None, clsctx, pythoncom.IID_I Dispatch) in . The parameters are (ADODB.Connecti on, 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?
a strange problem in python multi-thread programming
Collapse
This topic is closed.
X
X
-
WU FUHENGTags: None -
Diez B. Roggisch
Re: a strange problem in python multi-thread programming
> Today,I found a strange problem in python multi-thread programming.Whe n I[color=blue]
> used function win32com.client .Dispatch('ADOD B.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.CoCre ateInstance(IDi spatch, None, clsctx,
> pythoncom.IID_I Dispatch) in . The parameters are (ADODB.Connecti on, 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?[/color]
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.Connectio n
is not supposed to be called in a multi-threaded environment?
--
Regards,
Diez B. Roggisch
Comment