Problems with gencache on Windows NT
gtalvola at nameconnector.com
Thu May 10 12:26:33 EDT 2001
At 12:44 AM 5/5/01 +0000, Mark Hammond wrote:
>Alex Martelli wrote:
>>"Geoff Talvola" <gtalvola at nameconnector.com> wrote in message
>>>So far I haven't had any problems, but I haven't seen anyone else
>>>recommending the use of EnsureDispatch, so I'll ask the question: Is there
>>>any reason _not_ to just use EnsureDispatch?
>>I'd be interested, because I don't know of any such reasons -- I've
>>gradually switched just about all my COM clients to
>> from win32com.client.gencache import EnsureDispatch as Dispatch
>> from win32com.client import Dispatch
>>so if there ARE counterindications I didn't notice I'd really
>>like being informed about them!-)
> There is one slight problem remaining with events. In some cases, the
> module is needed before it is generated. I can't remember the exact
> problem at the moment.
> However, this is just an implementation problem, and the only thing left
> from moving to use this as the default.
Actually, I just today discovered a gotcha with using EnsureDispatch. It
appears to be non-thread-safe. If multiple threads are simultaneously
trying to EnsureDispatch, I get problems.
My solution for now is to just use EnsureModule at import time, but that
obviously defeats the purpose of EnsureDispatch.
So it would be nice if EnsureDispatch could be made thread-safe. Another
solution would be to allow EnsureModule to be passed in a nice string like
"Scripting.Dictionary" instead of the GUID, to make it nicer to use.
- Geoff Talvola
gtalvola at NameConnector.com
More information about the Python-list