Need help with COMObject for Zope

Toby Dickenson mbel44 at dial.pipex.net
Fri Apr 28 10:05:05 CEST 2000


tseaver at starbase.neosoft.com (Tres Seaver) wrote:

>>Add the 2 lines:
>>import pythoncom
>>pythoncom.CoInitialize()

NOOOoooooooo.......

>>before your code, and it will almost certainly work.
>>
>>The Zope guys should document this fairly well.  Note that Zope is almost
>>certainly initializing COM on a different thread than your code is being
>>called on (hence you see this message) - but there are some serious
>>implications with COM and threading.  

Yes, this is definitely a problem. Zope products can't always play by
the apartment threading rules, therefore you _must_ call
CoInitializeEx(COINIT_MULTITHREADED).

>I dont believe you will hit them here, but someone will sometime :-)
>
>We have a bug in the Collector on the COMObject project for this issue:
>
>  http://classic.zope.org:8080/Collector/842/view
>
>The bug page has three distinct workarounds:  one is essentially what
>Mark posted (it has some ugly issues, but will work, slowly, for most code);

^^^^^^^^^
>one requires hooking the thread creation to perform the CoInitialize() then;

....and works for all code ;-)



Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list