Module initialization problem when using COM

Robin Boerdijk robin.boerdijk at nl.origin-it.com
Tue May 25 06:59:06 EDT 1999


Mark Hammond <MHammond at skippinet.com.au> wrote in message
news:7icobr$9o$1 at m2.c2.telstra-mm.net.au...
> [From comp.lang.python; cc to the PythonCOM developers mailing list]
> Christian Tismer wrote in message
> <37495899.62DA32ED at appliedbiometrics.com>...
>
> >Without having tried, here my guess: (may be very wrong)
>
> Also without trying, here is my guess, which is very close to yours.
>
> When Python is hosting a COM object, it tries to be a good citizen by
> cleaning up.  When the last PythonCOM object destructs, Python is
finalized.
> When the first PythonCOM object is created, Python is initialized.
>
> This means that the process of creating one COM object, freeing it, then
> creating another is transitioning between these states.  As Python has
been
> finalized and reinitialized, the imports are indeed happening again, as
you
> would expect in this scenario.

But you would also expect the .dll of the extension module to be unloaded
and reloaded so that the state of the .dll is cleared. As Christian
suggests, the .dll somehow doesn't  get unloaded and reloaded an I wonder if
this isn't a VB problem. Maybe the following may shed some light into the
matter.

As a workaround to our original problem, we moved the CreateObject() to the
Form_Load() sub of VB so that it would only be called once per instance of
the VB program. However, the problem is still there because when we restart
the program within the VB development environment (so that CreateObject() is
called again), the counter of our test extension module is incremented and
not cleared to zero. Only when we build a stand-alone executable can we stop
and restart the program without problems (which implies that everything gets
unloaded and reloaded as expected).

> Either way, it does appear that this is the underlying ILU problem.  I
would
> guess we could invoke the same behaviour from a test program that init'd
> then finalized then re-init'd Python before again using ILU.  Is this
> possible to confirm?

I'd be happy to try a few of these things if only I understood you want to
be done exactly ;-)

(Note that the problem is not in ILU. ILU just complains about it. The
"empty" test module from my original post is probably all that is needed for
testing things.)

Robin








More information about the Python-list mailing list