Module initialization problem when using COM

Christian Tismer tismer at appliedbiometrics.com
Mon May 24 09:48:09 EDT 1999


Robin Boerdijk wrote:
> 
> Mark Hammond <MHammond at skippinet.com.au> wrote in message
> news:7i4sgb$3c5$1 at m2.c2.telstra-mm.net.au...
> >
> > Robin Boerdijk wrote in message
> >
> <0E16861EE7BCD111BE9400805FE6841F0949A5B2 at c1s5x001.cor.srvfarm.origin-it.com
> > >...
> > >We have the following problem: The initialization function of the ILU
> > >extension module gets called more than once when used within a Python COM
> > >server and called from Visual Basic (and this makes ILU crash).
> > >
> 
> <snip>
> 
> > Well, I would have to say it is a PythonCOM problem somehow.  This is
> > clearly voilating how Python says imports will work.  But for the life of
> me
> > I cant see why this is happening without running the code.  Fortunately
> you
> > provided a nice set of test code - thanks!  Unfortunately, I dont have
> time
> > at the moment - but I will try and sort this before I release my next
> build.

Without having tried, here my guess: (may be very wrong)

Since you create always a fresh COM server, I believe
the Python COM server tries to unload itself all the time.
For some reason, your .dll module is not released from
memory (well, somebody does a loadlibrary() too often?)
and is kept in memory.
The next COM server imports the module again, but this
is still there, with state from before.

Not sure if that can be.
But as a quick possible solution:
Create a second COM server in your main form and keep it.
AFAIK, currently all COM servers are served by one
Python process.

A simple helper would be a CreateObject("python.interpreter")
which doesn't hurt, you are loading the dlls anyway.

I would not wonder if your counter would now be always 1.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home




More information about the Python-list mailing list