[python-win32] Re: how to load 2 python COM DLLs in single app?

Thomas Heller theller at python.net
Fri Oct 29 20:32:17 CEST 2004


Niki Spahiev <niki at vintech.bg> writes:

> Thomas Heller wrote:
>> Back to the original problem (using several frozen dll com servers in a
>> single process), I envision these solutions, in increasing order of
>> difficulty:
>> 1. Patch py2exe's code so that sys.path is not replaced but extended
>> when Python is already initialized.  This gives no isolation between the
>> com dlls (and the main process, if it also uses Python) at all.
>> 2. Run the com dll servers in different interpreters, with
>> Py_NewInterpreter(). According to the python docs, extension modules
>> are still shared - this may be good, or may be bad.
>> 3. Create completely standalone, single file dlls, with no external
>> python.dll needed.
>
> New idea:
>
> 4. Use load_dynamic() and prefix all dlls
>
> _socket.pyd => prefix_socket.pyd
>
> then load_dynamic( "_socket", path + "prefix_socket.pyd" )
>
> and also rename py*23.dll to py*MN.dll (where M,N are random
> characters) and patch all pyd files to import from new names.
>
> This looks like complete separation.
>
> comments?
>
> Niki Spahiev
>
> P.S. maybe even prefix = MN

Sure, this should work.

But it may be more complicated than it seems at first, because the
extension dlls may link to each other dynamically (for example,
pythoncom.dll links to pywintypes.dll), and, again, pythoncom.dll and
pywintypes.dll are loaded via special mechanisms already.

Thomas



More information about the Python-win32 mailing list